【MFC】VC 删除目录和文件

static void DeleteDirectories(CString csPath)
{	
	CFileFind finder;
	CString tempPath;
	tempPath.Format("%s%s", csPath, "//*.*");
	BOOL bWork = finder.FindFile(tempPath);
	while(bWork)
	{		
		bWork = finder.FindNextFile();
		if(!finder.IsDots())
		{
			if(finder.IsDirectory())
			{
				DeleteDirectories(finder.GetFilePath());
			}
			else
			{
				DeleteFile(finder.GetFilePath());
			}
		}
	}
	finder.Close();
	RemoveDirectory(csPath);
}

你可能感兴趣的:(【MFC】VC 删除目录和文件)