【发布时间】:2012-12-08 09:51:17
【问题描述】:
此要求非常具体地用于读取目录内容以及所有子文件和文件夹的修改日期。在 Windows 中,我们有一些 API,但我在 Mac OS 开发中没有找到类似的功能。我搜索了这个,发现可以使用 NSFileManager。我找到了一个可以在 Documents 目录下获取路径内容的地方。
这是我拥有的一段代码。
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsPath = [paths objectAtIndex:0];
NSFileManager *manager = [[NSFileManager alloc] init];
NSDirectoryEnumerator *fileEnumerator = [manager enumeratorAtPath:documentsPath];
for (NSString *filename in fileEnumerator) {
// Do something with file
NSLog(@"file name : %@",filename );
}
但我的要求是在机器上的任何路径下找到所有子文件和文件夹修改日期的内容。请指导我。
谢谢, 陶西夫。
【问题讨论】: