【发布时间】:2015-10-20 20:10:21
【问题描述】:
我需要制作一个可以从 USB 设备运行的 mac 应用程序。该应用程序是一个产品演示应用程序。我需要检查是否存在某个目录以定义我可以显示的产品类别。如果某个类别的目录未退出,则不会显示该类别。然后我必须检查每个类别目录中的所有 jpg 文件并存储它们以便在用户选择一个时显示它们。
我的问题是我不知道如何从 USB 设备访问文件。我想我可以用这样的方式列出内容:
NSFileManager *fileManager = [[NSFIleManager alloc] init];
NSString *usbRootPath = [fileManager currentDirectoryPath];
// Reading the root content
NSArray *fileList = [fileManager contentAtDirectoryAtPath:usbRootPath error:NULL];
// Printing the content
for(int counter=0; counter < [fileList count]; counter++)
NSLog(@"%@", [fileList objectAtIndex:counter]);
usbRootPath(在我构建应用程序并将其复制到 USB 之后)是“/”,内容列表包含系统驱动器中的所有目录/文件。
我如何读取/验证位于 USB 驱动器上的目录的文件/目录/内容(我的应用程序在根目录中复制)。
任何帮助将不胜感激! 提前致谢!
【问题讨论】:
标签: macos cocoa nsfilemanager