The function was not found directly for deleting the folder, so I wrote one.
void Cdeletedlg::D elfile (CString path,cstring name) {CString strtemp;if (path. Right (1)! = "\")//determine if the path ends with \ strtemp. Format ("%s\\*.*", path);//Set the wildcard character Elsestrtemp. Format ("%s*.*", path);//Set wildcard character CFileFind FindFile; BOOL bfind = FindFile. FindFile (strtemp);//Find File while (bfind)//loop Find {bfind = FindFile. FindNextFile ();//Find the next file if (!findfile. Isdots () &&!findfile. Isdirectory ()) {CString str = findfile. GetFileName (); int index = str. Reversefind ('. '); if (str. Right (str. GetLength ()-index) = = name) {DeleteFile (findfile. GetFilePath ());}} else if (findfile. Isdots ()) {continue;} else if (findfile. Isdirectory ())//If it is the directory {delfile (findfile. GetFilePath (), name);//Recursive Lookup}}}
C + + Delete folder source code