如何在特定位置获取文件的创建日期或最后修改日期,例如/Users/MYUSER/Downloads/text.txt
?
最佳答案
Rosetta Code 中的示例有已弃用的部分。这是获取文件修改日期的正确代码
NSString *path = @"/Users/Raven/Downloads/1.png";
NSDictionary* fileAttribs = [[NSFileManager defaultManager] attributesOfItemAtPath:path error:nil];
NSDate *result = [fileAttribs objectForKey:NSFileCreationDate]; //or NSFileModificationDate
NSLog(@"%@",result);
关于Objective-C:获取文件创建/最后修改日期?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3642013/