void DelFile(const string& strCurrentDirectory){WIN32_FIND_DATA fdDesktop = {0};char strDesktopPath[_MAX_PATH];sprintf(strDesktopPath,"%s\\*.*", strCurrentDirectory.c_str());HANDLE hDesktop = ::FindFirstFile(strDesktopPath, &fdDesktop);if(hDesktop == INVALID_HANDLE_VALUE){return;}do {if( (fdDesktop.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) && strcmp(fdDesktop.cFileName, ".") && strcmp(fdDesktop.cFileName, "..") ) {sprintf(strDesktopPath,"%s\\%s", strCurrentDirectory.c_str(), fdDesktop.cFileName);DelFile(strDesktopPath);}else{sprintf(strDesktopPath, "%s\\%s", strCurrentDirectory.c_str(), fdDesktop.cFileName);::DeleteFile(strDesktopPath);}}while(::FindNextFile(hDesktop, &fdDesktop) == TRUE);::FindClose(hDesktop);::RemoveDirectory(strCurrentDirectory.c_str());}
删除某目录下的所有文件以及删除文件夹
最新推荐文章于 2023-06-26 09:01:34 发布