本文共 959 字,大约阅读时间需要 3 分钟。
NSString *strPath =[[NSBundle mainBundle] pathForResource:@"test.plist" ofType:nil];
NSLog(@"path:%@", strPath);
NSFileManager *fileManager = [NSFileManager defaultManager];
NSString *path = strPath;//@"/tmp/List";
NSError *error = nil;
NSDictionary *fileAttributes = [fileManager attributesOfItemAtPath:path error:&error];
if (fileAttributes != nil) {
NSNumber *fileSize = [fileAttributes objectForKey:NSFileSize];
NSString *fileOwner = [fileAttributes objectForKey:NSFileOwnerAccountName];
NSDate *fileModDate = [fileAttributes objectForKey:NSFileModificationDate];
NSDate *fileCreateDate = [fileAttributes objectForKey:NSFileCreationDate];
if (fileSize) {
NSLog(@"File size: %qi\n", [fileSize unsignedLongLongValue]);
}
if (fileOwner) {
NSLog(@"Owner: %@\n", fileOwner);
}
if (fileModDate) {
NSLog(@"Modification date: %@\n", fileModDate);
}
if (fileCreateDate) {
NSLog(@"create date:%@\n", fileModDate);
}
}
else {
NSLog(@"Path (%@) is invalid.", path);
}
转载地址:http://wwwbi.baihongyu.com/