BOOL DeleteFolder(CString strFolder,BOOL bSelf/*=TRUE*/) { CFileFind finder; CString strWildcard(strFolder); strWildcard += _T("\*.*"); BOOL bWorking = finder.FindFile(strWildcard); if (!bWorking) { finder.Close(); return FALSE; } BOOL bSuc=TRUE; while(bWorking) { bWorking = finder.FindNextFile(); if (finder.IsDots()) continue; if (finder.IsDirectory()) { CString str = finder.GetFilePath(); if (!DeleteFolder(str,TRUE)) { bSuc = FALSE; break; } } else { CString str = finder.GetFileName(); str = strFolder + _T("\") + str; BOOL bSuccess = ::DeleteFile(str); if (!bSuccess) { bSuc = FALSE; break; } } } finder.Close(); if (bSuc && bSelf) { bSuc = ::RemoveDirectory(strFolder); } return bSuc; }