如何访问文件修改日期
NSString *docsDir = [NSHomeDirectory() stringByAppendingPathComponent:
@"TempiPad"];
NSFileManager *localFileManager=[[NSFileManager alloc] init];
NSDirectoryEnumerator *dirEnum =
[localFileManager enumeratorAtPath:docsDir];
NSString *file;
// List all files in docsDir
while (file = [dirEnum nextObject]) {
NSLog(@"File = %@",file);
NSError *attributesError = nil;
NSDictionary *fileAttributes = [[NSFileManager defaultManager] attributesOfItemAtPath:file error:&attributesError];
NSString *fileModificationDate = [fileAttributes objectForKey:NSFileModificationDate];
NSLog(@"ModDate = %@",fileModificationDate);
}
}
这只是输出(空)。最终我会想要比较两个文件的 fileModificationDate,那么我该怎么做呢?