void DeleteDir(LPCTSTR lpszDir)
{
WIN32_FIND_DATA wfd;
TCHAR szFile[MAX_PATH];
TCHAR szDelDir[MAX_PATH];
lstrcpy(szDelDir, lpszDir);
wsprintf(szFile, TEXT("%s\\*.*"), lpszDir);
HANDLE hFindFile = FindFirstFile(szFile, &wfd);
if ( INVALID_HANDLE_VALUE == hFindFile )
return;
BOOL bFind = TRUE;
while ( bFind )
{
bFind = FindNextFile(hFindFile, &wfd);
if ( lstrcmpi(wfd.cFileName, TEXT(".")) == 0 ||
lstrcmpi(wfd.cFileName, TEXT("..")) == 0 )
continue;
wsprintf(szFile, TEXT("%s\\%s"), szDelDir, wfd.cFileName);
if ( wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY )
DeleteDir(szFile);
else
DeleteFile(szFile);
}
FindClose(hFindFile);
RemoveDirectory(szDelDir);
}
|