用VC如何实现FTP下载

ZengYongChun 2000-11-27 07:42:00

你好:
感谢你能帮我解决一个相当重要的事情!我想题一个问题:
我在用CFtpConnection::PutFile(...) 命令后发现FTP服务器上的文件
(就是要下载的文件)不能删除,告诉我此文件正在使用.但是此文件有的确下载成功!
程序中我写:
pFTPcon->GetFile(m_remoteFile,strTemp,FALSE);

我现在要删除此文件该如何实现?请告诉我, 万分感谢!!!

(我有删除权限,并且我的删除代码绝对无误!)
...全文
370 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
ZengYongChun 2000-11-28
  • 打赏
  • 举报
回复
谢谢你能帮我的忙,但是,我刚调试过,仍不行..
谢谢再赐教!!!
ZengYongChun 2000-11-28
  • 打赏
  • 举报
回复
谢谢你能帮我的忙,但是,我刚调试过,仍不行..
谢谢再赐教!!!
Searph 2000-11-28
  • 打赏
  • 举报
回复
同样的问题,同样的说明,sigh..
PutFile is a high-level routine that handles all of the operations associated with storing a file on an FTP server. Applications that only send data, or that require closer control over the file transfer, should use OpenFile and CInternetFile::Write.

RedFire 2000-11-28
  • 打赏
  • 举报
回复
呵呵。你可以试试下面的方法:
先get;
再put;
再delete;
不要笑我。
ZengYongChun 2000-11-28
  • 打赏
  • 举报
回复
我在用GetFile(下载文件)后关闭pFTPcon.close后,也不行.
谢谢再赐教!!!
朝阳群众001 2000-11-28
  • 打赏
  • 举报
回复
下载文件后QUIT一下,关掉Session试试?
ZengYongChun 2000-11-28
  • 打赏
  • 举报
回复
putfile(上传文件)后可以立即删除,
但是getfile(下载文件)后文件(自认为处于打开状态)再删除将无法删除,
服务器方手工删除也报告文件正在使用,不能删除,只有重启动.
问:如和在getfile后关闭文件.万分感激!!!
.我写的是一个FTP-OCX控件:代码如下:
pFTPcon=eSession.GetFtpConnection(m_remoteAddress,m_userName,m_password);

BOOL CFTPCtrl::GetFile() file://下载文件
{
pFTPcon->SetCurrentDirectory(m_remoteDirectory);
CString strTemp;
CString strAdd="\\";
strTemp=m_localDirectory;
if(strTemp.GetLength()==3)
{
strTemp.Insert(strTemp.GetLength(),m_localFile);
}
else
{
strTemp.Insert(strTemp.GetLength(),strAdd);
strTemp.Insert(strTemp.GetLength(),m_localFile);
}
pFTPcon->GetFile(m_remoteFile,strTemp,FALSE);
return TRUE;
}

BOOL CFTPCtrl::PutFile() file://上传文件
{
// TODO: Add your dispatch handler code here
pFTPcon->SetCurrentDirectory(m_remoteDirectory);
CString strTemp;CString strAdd;strAdd="\\";
strTemp=m_localDirectory;
if(strTemp.GetLength()==3)
{
strTemp.Insert(strTemp.GetLength(),m_localFile);
}
else
{
strTemp.Insert(strTemp.GetLength(),strAdd);
strTemp.Insert(strTemp.GetLength(),m_localFile);
}
if(m_binary==TRUE)
{return pFTPcon->PutFile(strTemp,m_remoteFile);}
else
{return pFTPcon->PutFile(strTemp,m_remoteFile,FTP_TRANSFER_TYPE_ASCII);}
}
RedFire 2000-11-27
  • 打赏
  • 举报
回复
你可以先用Windows自带的ftp.exe试一下。在你的程序PutFile之后,看它能不能删除?

16,473

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • Web++
  • encoderlee
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……

试试用AI创作助手写篇文章吧