我正在尝试查找文件的创建日期(不是修改日期).
虽然修改日期是,但创建日期似乎不在文件的属性中.
我正在使用此代码..
NSFileManager* fm = [NSFileManager defaultManager];
NSString* path = [PathHelpers pathInDocumentsFolderWithFilename:FILE_NAME];
NSDictionary* attrs = [fm attributesOfItemAtPath:path error:nil];
if (attrs != nil) {
return (NSDate*)[attrs objectForKey: NSFileCreationDate];
} else {
return nil;
}
Run Code Online (Sandbox Code Playgroud)
这总是返回零.在调试器中键入"po attrs"以获取NSDictionary中的键/值对列表将返回以下内容.
NSFileGroupOwnerAccountID = 20;
NSFileGroupOwnerAccountName = staff;
NSFileModificationDate = 2010-01-21 11:47:55 +0000;
NSFileOwnerAccountID = 501;
NSFileOwnerAccountName = ben;
NSFilePosixPermissions = 420;
NSFileReferenceCount = 1;
NSFileSize = 338;
NSFileSystemFileNumber = 2234;
NSFileSystemNumber = 42553324;
NSFileType = NSFileTypeRegular;
没有创作日期..呸..
任何人都知道另一种获取创建日期的方式,还是只是在iOS中不存在?
我有一个应用程序,我在其中记录声音文件并将其存储在应用程序文档目录中.
我想要的是,它应该只包含昨天和更旧的文件,并从iPhone应用程序中的文件夹中删除所有其他文件.有没有办法做到这一点?
谢谢 ..