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);
}
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);
}
相关文章推荐
- [iOS]我的github
- iOS 后台进入前台刷新当前界面
- 《招聘一个靠谱的 iOS》—参考答案(下)
- iOS 沙盒的使用 写入 读出,删除
- 整理常用的iOS第三方资源
- 《招聘一个靠谱的 iOS》—参考答案(上)
- iOS开发——keychain的使用
- iOS性别枚举
- IOS 通过苹果开放API检测更新
- iOS计算文字高度
- ios 7 statusbar 状态栏 跟随navigationbar的颜色而改变
- iOS开发-ios7下拉刷新,上提加载快速集成
- iOS学习之——NSRunLoop
- iOS组件化思路-大神博客研读和思考
- iOS学习之——#import与@class的区别
- iOS 开发- 键盘类型
- iOS学习之—— NSDateComponents
- iOS 学习之—— NSDateFormatter
- iOS CocoaPods1.0.0的一些基础知识
- iOS获取设备方向(锁屏状态下通用)