本地目录:
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);
}