void CBubbleMachineDlg::DeleteDirectory(CString strDir)
{
TCHAR szFind[MAX_PATH] = { _T("\0") };
lstrcpyn(szFind, strDir, MAX_PATH);
lstrcat(szFind, _T("\\*.*")); //指明通配符,读取所有文件和目录
CFileFind finder;
BOOL bfind = finder.FindFile(szFind, 0);
while (bfind)
{
bfind = finder.FindNextFile();
if (finder.IsDots())
{
continue;
}
SetFileAttributes(finder.GetFilePath(), FILE_ATTRIBUTE_NORMAL);
if (finder.IsDirectory())
{
DeleteDirectory(finder.GetFilePath());
RemoveDirectory(finder.GetFilePath());
}
else
{
//DeleteFile(finder.GetFilePath()); //删除文件(包括目录下的)
}
}
RemoveDirectory(strDir);
//finder.Close();
}