Bool deletedirectory (wchar_t * wscdirectory) <br/>{< br/> cstring strdirectory = wscdirectory; <br/> cstring strfile = strdirectory + L "//*. * "; <br/> cfilefind tempfind; </P> <p> bool isfinded = tempfind. findfile (strfile); <br/> while (isfinded) <br/>{< br/> isfinded = tempfind. findnextfile (); <br/> If (! Tempfind. isdots () <br/>{< br/> cstring strfoundfile = tempfind. getfilepath (); <br/> If (tempfind. isdirectory () <br/>{< br/> deletedirectory (strfoundfile. getbuffer (); <br/>}< br/> else <br/>{< br/> deletefile (strfoundfile ); <br/>}< br/> tempfind. close (); <br/> If (! Removedirectory (strdirectory) <br/>{< br/> return false; <br/>}< br/> return true; <br/>}
API function bool winapi removedirectory (_ in lpctstrLppathnameIs used to delete folders. However, if there are files or subfolders in the folder, the function will fail to be executed. Therefore, you must recursively Delete subfolders and files.
The above code implements this function