1、该函数是删除文件夹下的所有文件
BOOL CMainFrame::DeleteDirectory(const CString &strPath)
{
CFileFind tempFind;
TCHAR sTempFileFind[MAX_PATH] = { 0 };
wsprintf(sTempFileFind, _T("%s\\*.*"), strPath);
BOOL IsFinded = tempFind.FindFile(sTempFileFind);
while (IsFinded)
{
IsFinded = tempFind.FindNextFile();
if (!tempFind.IsDots())
{
TCHAR sFoundFileName[200] = { 0 };
_tcscpy(sFoundFileName, tempFind.GetFileName().GetBuffer(200));
if (tempFind.IsDirectory())
{
TCHAR sTempDir[200] = { 0 };
wsprintf(sTempDir, _T("%s\\%s"),strPath, sFoundFileName);
DeleteDirectory(sTempDir); //删除文件夹下的文件
RemoveDirectory(sTempDir); //移除空文件
}
else
{
TCHAR sTempFileName[200] = { 0 };
wsprintf(sTempFileName, _T("%s\\%s"), strPath, sFoundFileName);
DeleteFile(sTempFileName);
}
}
}
tempFind.Close();
// if(!RemoveDirectory(strPath))
// return false;
return true;
}