标签:
提供一种获取iOS文件夹大小的方法。没有使用对文件夹内的文件枚举与文件大小字节数的累加。NSURL *cacheDirectory = [[NSFileManager defaultManager] URLForDirectory:NSCachesDirectory inDomain:NSUserDomainMaskappropriateForURL:nil create:NO error:nil];
NSDictionary *attributes = [[NSFileManager defaultManager] attributesOfItemAtPath:cacheDirectory.path error:nil];
NSNumber *sizeNumber = attributes[@"NSFileSize"];
self.cacheDirectorySize.text = [NSStringstringWithFormat:@"%.1fM",sizeNumber.integerValue/1024.];
标签:
原文地址:http://blog.csdn.net/learnios/article/details/44134043