How do I delete a directory and all of the files inside of it, including the read-only files?
There is no Shell function that deletes a directory and all of its files, so we can use Feroz’s function: Uses the Windows API: //By Feroz Zahid BOOL DeleteDirectory(const TCHAR* sPath) { HANDLE hFind; // file handle WIN32_FIND_DATA FindFileData; TCHAR DirPath[MAX_PATH]; TCHAR FileName[MAX_PATH]; _tcscpy(DirPath,sPath); _tcscat(DirPath,”\\*”); // searching all files _tcscpy(FileName,sPath); _tcscat(FileName,”\\”); hFind = FindFirstFile(DirPath,&FindFileData); // find the first file if(hFind == INVALID_HANDLE_VALUE) return FALSE; _tcscpy(DirPath,FileName); bool bSearch = true; while(bSearch) { // until we finds an entry if(FindNextFile(hFind,&FindFileData)) { if(IsDots(FindFileData.cFileName)) continue; _tcscat(FileName,FindFileData.cFileName); if((FindFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) { // we have found a directory, recurse if(!DeleteDirectory(FileName)) { FindClose(hFind); return FALSE; // directory couldn’t be deleted } RemoveDirectory(FileName); // remove the em