- (CGFloat)getFileSize:(NSString *)path
{
NSFileManager *fileManager = [NSFileManager defaultManager];
float filesize = - 1.0;
if ([fileManager fileExistsAtPath:path]) {
//获取文件的属性
NSDictionary *fileDic = [fileManager attributesOfItemAtPath:path error:nil];
unsigned long long size = [[fileDic objectForKey:NSFileSize] longLongValue];
filesize = 1.0 * size / 1024 / 1024;
}else{
NSLog(@"文件不存在");
}
return filesize;
} |
|