- NSString *strPath =[[NSBundle mainBundle] pathForResource:@"lomo.jpg" 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);
- }
如何查看iOS沙盒中文件的属性(修改日期,创建日期,大小等)
最新推荐文章于 2022-10-17 01:05:08 发布