//--- Calculate a folder size ---//------Get all sub-files under a folder (this example is a folder named HomePath path)Nsarray* Subfiles =[Manager1 Subpathsatpath:homepath]; //used to count each file size Longsum =0; for(nsstring* subpathinchsubpaths) { //The full path of the mosaic Word filensstring* Path =[HomePath Stringbyappendingpathcomponent:subpath]; //get a Dictionary of file propertiesnsdictionary* att =[Manager1 Attributesofitematpath:path Error:nil]; //get the file size based on the property dictionarynsnumber* size =[Att objectforkey:nsfilesize]; //Converts a file size to a Long value plus sumSum + =Size.longvalue; } //the folder size can be obtained at the end of the loop (convert bytes and KB depending on the situation, some conversions are 1024, and some are.)NSLog (@"%ld KB", sum/1024x768);
iOS calculates a folder size