Tree node file size folder size

Source: Internet
Author: User

For personal backup purposes only
 

 
// Obtain the common file size DWORD getnormalfilesize (cstring srcfilepath) {ifstream filein (srcfilepath, IOS: In); filein. seekg (0, IOS: End); DWORD normalfilesize = filein. tellg (); Return normalfilesize ;}

 

// Obtain the folder size DWORD getdirectoryfilesize (cstring srcfilepath) {DWORD directoryfilesize = 0; // unsigned lOng/* srcfilepath + = _ T ("*. * "); */bool isexist = false; cfilefind finder; isexist = finder. findfile (srcfilepath + _ T ("\\*. * "); If (! Isexist) {return 0;} while (isexist) {isexist = finder. findnextfile (); If (finder. isdots () // if it is ". "(current directory) or ".. "(parent directory) {continue;} cstring tempsrcfilepath = finder. getfilepath (); If (finder. isdirectory () // folder directory {directoryfilesize + = getdirectoryfilesize (tempsrcfilepath);} else // file directory {// create file handle currentfile = createfile (tempsrcfilepath, // file name or path 0, 0, 0, open_existing, // open the file and read 0, 0); directoryfilesize + = getfilesize (currentfile, 0);} return directoryfilesize ;}

 

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.