关于FTP删除文件,CFtpConnection::Remove红字部分无法实现
FTP上存在一个文件,再上传上去怎么才能覆盖,我用REMOVE原文件一直失败,求大神指点
CFtpFileFind finder(pConnection);
int bWorking = finder.FindFile("*");
CString strFileName;
BOOL fc = FALSE;
while (bWorking)
{
bWorking = finder.FindNextFile();
strFileName = finder.GetFileName();
if(strFileName == FtpPath)
{
fc = TRUE;
break;
}
}
if (!fc)
{
pConnection->CreateDirectory(FtpPath);
}
pConnection->SetCurrentDirectory(FtpPath);
pConnection->GetCurrentDirectory(FtpPath);
//AfxMessageBox(FtpPath);
CFileFind ff;
CString strDirectory=LocalPath+_T("\\") +_T("\\*.*");
//AfxMessageBox(LocalPath);
BOOL ret = ff.FindFile(strDirectory);
while(ret)
{
//AfxMessageBox(strDirectory);
ret = ff.FindNextFile();
if (ret != 0)
{
//AfxMessageBox(strDirectory);
if (!ff.IsDirectory() && !ff.IsDots())
{
CString name = ff.GetFileName();
CString path = ff.GetFilePath();
//AfxMessageBox(LocalPath+ '\\' + name);
bWorking = finder.FindFile(FtpPath + "/*.*");
// CString strFileName;
fc = FALSE;
while (bWorking)
{
bWorking = finder.FindNextFile();
if (!finder.IsDots()&&!finder.IsDirectory())
{
strFileName = finder.GetFileName();
if(strFileName == name)
{
fc = TRUE;
break;
}
}
}
// finder.Close();
pConnection->SetCurrentDirectory(FtpPath);
pConnection->GetCurrentDirectory(FtpPath);
//FtpPath = FtpPath.Right(FtpPath.GetLength() - 1);
if (!fc)
{
AfxMessageBox(FtpPath + '\\' + name);
if (pConnection->Remove( FtpPath + '/' + name))
{
AfxMessageBox(FtpPath + '/' + name);
}
else
{
AfxMessageBox("remove fail.");
}
}
// //
if (!pConnection->PutFile( LocalPath+ '\\' + name , FtpPath + '\\' + name))
{
MessageBox("Error getting file");
}
}
}
}