This will delete a directory and all of its contents: static BOOL DeleteDirectoryPath(const CString& path) { // Function to delete a directory, including the case where // files and sub-directories exist. Also deletes the name specified, // if it is actually a file. WIN32_FIND_DATA find; HANDLE findHandle; CString file, filePattern; DWORD fileAttrib, err; filePattern = path + "\\*.*"; findHandle = FindFirstFile(filePattern, &find); while (findHandle != INVALID_HANDLE_VALUE) { if ((strcmp(find.cFileName, ".") != 0) && (strcmp(find.cFileName, "..") != 0)) { file.Format("%s\\%s", path, find.cFileName); if (find.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) { if (! DeleteDirectoryPath(file)) { return FALSE; } } else { SetFileAttributes(file, FILE_ATTRIBUTE_NORMAL); //Prevents some deletion failures if (! DeleteFile(file)) { return FALSE; } } } if (! FindNextFile(findHandle, &find)) break; } FindClose(findHandle); fileAttrib = GetFileAttributes(path); if (fileAttrib == 0xFFFFFFFF) { err = GetLastError(); if (err == ERROR_FILE_NOT_FOUND) { return TRUE; } else { return FALSE; } } else if (fileAttrib & FILE_ATTRIBUTE_DIRECTORY) { if (! RemoveDirectory(path)) { return FALSE; } } else { SetFileAttributes(path, FILE_ATTRIBUTE_NORMAL); //Prevents some deletion failures if (! DeleteFile(path)) { return FALSE; } } return TRUE; } cheers, Neil