您的位置:首页 > 移动开发 > IOS开发

iOS 文件属性

2016-05-19 11:10 459 查看
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);

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: