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 ;}