- (float)getCacheFileSize
{
NSFileManager *fileManager = [NSFileManager defaultManager];
double fileSize = 0.0;
NSString *cachPath = [NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES) objectAtIndex:0];
NSArray *files = [fileManager subpathsAtPath:cachPath];
for (NSString *fileName in files)
{
NSString *path = [cachPath stringByAppendingPathComponent:fileName];
if ([fileManager fileExistsAtPath:path])
{
NSDictionary *fileAttributes = [fileManager attributesOfItemAtPath:path error:nil];
fileSize += (double)([fileAttributes fileSize]);
}
}
return fileSize/( 1024.0 * 1024.0);
}
网友评论