Recursive delete directory

zhaozj2021-02-16  103

// Remissive Delete Directory

BOOL CNAMEVIEW :: 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, Tempfind.getFileName (). getBuffer (200));

IF (Tempfind.Indirectory ())

{

CHAR TEMPDIR [200];

Sprintf (Tempdir, "% S / /% S", DIRNAME, FOUNDFILENAME);

DELETEDIRECTORY (TEMPDIR);

}

Else

{

Char TempFileName [200];

Sprintf (TempFileName, "% S / /% S", DIRNAME, FOUNDFILENAME

Deletefile (TempFileName);

}

}

}

Tempfind.close ();

IF (! RemoveDirectory (DIRNAME))

{

AfxMessageBox ("Delete an error!");

Return False;

}

Return True;

}

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

New Post(0)