删除文件夹
				17.删除文件夹
// 删除文件夹及其所有内容
void CBaseDoc::RemoveFolder(const CString &strPathName)
{
CString path = strPathName;
if (path.Right(1) != _T("\\"))
path += _T("\\");
path += _T("*.*");
CFileFind ff;
BOOL res = ff.FindFile(path);
while (res)
{
res = ff.FindNextFile();
// 是文件时直接删除
if (!ff.IsDots() && !ff.IsDirectory())
DeleteFile(ff.GetFilePath());
else if (ff.IsDots())
continue;
else if (ff.IsDirectory())
{
path = ff.GetFilePath();
// 是目录时继续递归,删除该目录下的文件
RemoveFolder(path);
::RemoveDirectory(path);
}
}
}
    
	
		
		
        
	
	
	
	
	
		
		
	
	
	
	
	// 删除文件夹及其所有内容
void CBaseDoc::RemoveFolder(const CString &strPathName)
{
CString path = strPathName;
if (path.Right(1) != _T("\\"))
path += _T("\\");
path += _T("*.*");
CFileFind ff;
BOOL res = ff.FindFile(path);
while (res)
{
res = ff.FindNextFile();
// 是文件时直接删除
if (!ff.IsDots() && !ff.IsDirectory())
DeleteFile(ff.GetFilePath());
else if (ff.IsDots())
continue;
else if (ff.IsDirectory())
{
path = ff.GetFilePath();
// 是目录时继续递归,删除该目录下的文件
RemoveFolder(path);
::RemoveDirectory(path);
}
}
}
		上一篇:std::find,std::find_if使用小结
		下一篇:MFC Telnet Application(mfc telnet 端口,代码实现、不调用telnet.exe)
	
 
		 评论加载中,请稍后...
    评论加载中,请稍后...