Delete all files and subdirectories in the directory and directory

zhaozj2021-02-11  168

Deleting Directory and Directory All files and subdirectories VC only provide functions that delete an empty directory, and uses a directory that often wants to delete a lot of subdirectories and files. In order to achieve this, I have written the DELETEDIRECTORY function that can be implemented. Function prototype: BOOL DELETEDIRECTORY (CHAR * DIRNAME); Return Value: Returns true when successfully delete, otherwise return false parameter DIRNAME is the directory name to be deleted, must be an absolute path name, such as "C: // Temp". Function is defined as follows: BOOL DeleteDirectory (char * DirName) {CFileFind tempFind; char tempFileFind [200]; sprintf (tempFileFind, "% s //*.*", DirName); BOOL IsFinded = (BOOL) tempFind.FindFile (tempFileFind) While (isfinded) {isfinded = (bool) tempfind.findnextFile (); if (! TempFind.isdots ()) {Char FoundFileName [200]; strcpy (FoundFileName (). getBuffer (200); if () {char Tempdir [200]; sprintf (tempdir, "% s //% s", dirname, findfilename; deletedirectory (Tempdir);} else {char TempFileName [200]; sprintf (TempFileName, "% s //% s", diRName, FoundFileName); deletefile (TempFileName);}}} tempfind.close (); if (! Removwdirctory) {MessageBox (0, "Delete Directory Failed!", "Warning Information ", MK_OK); Return False;} Return True;

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

New Post(0)