From:http://snowyshell.blog.163.com/blog/static/2209140342013924114349573/
-(float)getFilePath{
//文件管理
NSFileManager *fileManager = [NSFileManager defaultManager];
//缓存路径
NSArray *cachePaths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory,NSUserDomainMask, YES);
NSString *cacheDir = [cachePaths objectAtIndex:0];
NSArray *cacheFileList;
NSEnumerator *cacheEnumerator;
NSString *cacheFilePath;
unsigned long long cacheFolderSize = 0;
cacheFileList = [fileManager subpathsOfDirectoryAtPath:cacheDir error:nil];
cacheEnumerator = [cacheFileList objectEnumerator];
while (cacheFilePath = [cacheEnumerator nextObject]) {
NSDictionary *cacheFileAttributes = [fileManager attributesOfItemAtPath:[cacheDirstringByAppendingPathComponent:cacheFilePath] error:nil];
cacheFolderSize += [cacheFileAttributes fileSize];
}
//单位MB
return cacheFolderSize/1024/1024;
}