递归删除本地目录和ftp目录

本地目录:

void CAutoDelete::DoRecursionLocalDelete(CString& localDirectory) {
CFileFind finder;
CString strFileName;
strFileName.Format("%s\\*.*", localDirectory);
BOOL found = finder.FindFile(strFileName);
while(found) {
found = finder.FindNextFile();
if(finder.IsDots()) {
continue;
}
strFileName = finder.GetFilePath();
if(finder.IsDirectory()) {
DoRecursionLocalDelete(strFileName);
} else {
DeleteFile(strFileName);
}
}
finder.Close();
RemoveDirectory(strFileName);
}

ftp目录:

void CAutoDelete::DoRecursionFtpDelete(CString& ftpDirectory) {
CFtpFileFind finder(m_pFtpConnection);
CString strFileName;
strFileName.Format("%s\\*.*", ftpDirectory);
BOOL found = finder.FindFile(strFileName);
while(found) {
found = finder.FindNextFile();
if(finder.IsDots()) {
continue;
}
strFileName = finder.GetFilePath();
if(finder.IsDirectory()) {
finder.Close();
DoRecursionFtpDelete(strFileName);
} else {
m_pFtpConnection->Remove(strFileName);
}
}
finder.Close();
m_pFtpConnection->RemoveDirectory(ftpDirectory);
}
上一篇:DEDE里有个编码问题,不支持PHP5.4及以上版本!


下一篇:js中的原形链问题