Created
October 26, 2013 13:28
-
-
Save TomLiu/7169481 to your computer and use it in GitHub Desktop.
Caculate a folder size
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
NSArray *filesArray = [[NSFileManager defaultManager] subpathsOfDirectoryAtPath:cachePath error:&error]; | |
NSEnumerator *filesEnumerator = [filesArray objectEnumerator]; | |
NSString *fileName; | |
unsigned long long int fileSize = 0; | |
while (fileName = [filesEnumerator nextObject]) { | |
NSString *filePath = [cachePath stringByAppendingPathComponent:fileName]; | |
NSDictionary *fileDictionary = [fm attributesOfItemAtPath:filePath error:&error]; | |
fileSize += [fileDictionary fileSize]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment