CFtpFileFind 不能使用两次,也就是说,在递归查询的时候,要采用别的方式。
MSDN这样解释:
ERROR_FTP_TRANSFER_IN_PROGRESS
The requested operation cannot be made on the FTP session handle because an
operation is already in progress.
//--------------以下为FtpClient删除文件夹的函数--递归方式-------------
BOOL CysDelFtpFile(LPCTSTR lpStrFile)
{
CString strFile;
strFile = lpStrFile;
strFile.TrimRight("/";
strFile += "/*.*";
CFtpFileFind ftpFinder(m_pFtpConnect);
if(!ftpFinder.FindFile(strFile))
{
ftpFinder.Close();
return FALSE;
}
BOOL bFinish = TRUE;
list<CString> listDirName;
while(bFinish)
{
bFinish = ftpFinder.FindNextFile();
if(ftpFinder.IsDots())
continue;
if(ftpFinder.IsDirectory())
{
CString strDir;
strDir.Format("%s/%s", lpStrFile, ftpFinder.GetFileName());
listDirName.push_back(strDir);
}
else
{
m_pFtpConnect->Remove(ftpFinder.GetFilePath());
}
}
ftpFinder.Close();
CString strDir;
//---这一段照搬了csdn上一位大侠的方法-------
while(listDirName.size() != 0)
{
strDir = *listDirName.begin();
listDirName.pop_front();
CysDelFtpFile(strDir);
m_pFtpConnect->RemoveDirectory(strDir);
}
return TRUE;
}
本文介绍CFtpFileFind类的一个使用限制——无法连续使用两次,并提供了一种通过递归方式删除FTP服务器上文件夹的具体实现方案。
603

被折叠的 条评论
为什么被折叠?



