bool DeleteDirectory( CString DirName)
{
CString PUBPATH;
PUBPATH=DirName;
CFileFind tempFind;
DirName+="\\*.*";
BOOL IsFinded=(BOOL)tempFind.FindFile(DirName);
while(IsFinded)
{
IsFinded=(BOOL)tempFind.FindNextFile();
CString str = tempFind.GetFileName();
if(!tempFind.IsDots())
{
CString strDirName;
strDirName+=PUBPATH;
strDirName+="\\";
strDirName+=tempFind.GetFileName();
if(tempFind.IsDirectory())
{
//strDirName += PUBPATH;
DeleteDirectory(strDirName);
}
else
{
SetFileAttributes(strDirName,FILE_ATTRIBUTE_NORMAL); //去掉文件的系统和隐藏属性
DeleteFile(strDirName);
}
}
}
tempFind.Close();
if(!RemoveDirectory(PUBPATH))
{
return false ;
}
return true;
}
{
CString PUBPATH;
PUBPATH=DirName;
CFileFind tempFind;
DirName+="\\*.*";
BOOL IsFinded=(BOOL)tempFind.FindFile(DirName);
while(IsFinded)
{
IsFinded=(BOOL)tempFind.FindNextFile();
CString str = tempFind.GetFileName();
if(!tempFind.IsDots())
{
CString strDirName;
strDirName+=PUBPATH;
strDirName+="\\";
strDirName+=tempFind.GetFileName();
if(tempFind.IsDirectory())
{
//strDirName += PUBPATH;
DeleteDirectory(strDirName);
}
else
{
SetFileAttributes(strDirName,FILE_ATTRIBUTE_NORMAL); //去掉文件的系统和隐藏属性
DeleteFile(strDirName);
}
}
}
tempFind.Close();
if(!RemoveDirectory(PUBPATH))
{
return false ;
}
return true;
}