Recursive call deletes all content under the folder and folder

xiaoxiao2021-04-03  240

Void Removetree (CString strparent) // recursive function {cstring stramp; cfilefind f; bool bfind = f.findfile (strparent "*. *"); while (bfind) {bfind = f.findnextFile (); if (f. ISDOTS ()) Continue; // File name "." Or ".." folder IF (f.IsDirectory ()) // folder {stratmp = strparent f.GetFileName () "//"; Removetree (strtmp); if (! RemoveDirectory ("Remove Directory% s Fial./N" ,strtmp.getBuffer (0));}} else // file {stramp = strparent f.GetFileName ); If (! DELETEFILE (STRTMP)) {Printf ("delete file% s fial./n" ,strtmp.getBuffer (0));}}}}

Void RemovedirandContent (CString strdir) {transovetree (strdir); if (! Removedirectory (strdir)) {Printf ("Remove Directory% s fial./n" ,strdir.getBuffer (0));}}

int _tmain (int argc, TCHAR * argv [], TCHAR * envp []) {CString strCurtDir; GetCurrentDirectory (_MAX_PATH, strCurtDir.GetBuffer (_MAX_PATH)); strCurtDir.ReleaseBuffer (); RemoveDirAndContent (strCurtDir "// test // "); Returnograph;}

转载请注明原文地址:https://www.9cbs.com/read-131633.html

New Post(0)