删除文件夹 递归
bool RemoveDir(const char* szFileDir)
{
std::string strDir = szFileDir;
if (strDir.at(strDir.length() - 1) != '\\')
strDir += '\\';
WIN32_FIND_DATAA wfd;
HANDLE hFind = FindFirstFileA((strDir + "*.*").c_str(), &wfd);
if (hFind == INVALID_HANDLE_VALUE)
return false;
do
{
if (wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
{
if (strcmp(wfd.cFileName, ".") != 0 &&
strcmp(wfd.cFileName, "..") != 0)
RemoveDir((strDir + wfd.cFileName).c_str());
}
else
{
DeleteFileA((strDir + wfd.cFileName).c_str());
}
} while (FindNextFileA(hFind, &wfd));
FindClose(hFind);
RemoveDirectoryA(szFileDir);
return true;
}