标签:
1.计算单个文件大小
+ (long long)fileSizeAtPath:(NSString*)filepath { NSFileManager* manager = [NSFileManager defaultManager]; if ([manager fileExistsAtPath:filepath]){ return [[manager attributesOfItemAtPath:filepath error:nil] fileSize]; } return 0; }
2.计算系统空间大小
/* *FOUNDATION_EXPORT NSString * const NSFileSystemSize;//系统总空间大小 *FOUNDATION_EXPORT NSString * const NSFileSystemFreeSize;//系统可使用空间大小 */ + (CGFloat)getStorage { NSDictionary *fattributes = [[NSFileManager defaultManager] attributesOfFileSystemForPath:NSHomeDirectory() error:nil]; NSNumber *num = [fattributes objectForKey:NSFileSystemFreeSize]; return [num longLongValue]/1024.0/1024.0/1024.0; }
标签:
原文地址:http://www.cnblogs.com/rgshio/p/4815626.html