iOS calculates a folder size

Source: Internet
Author: User

//--- 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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.