向各位前辈求救:vfp与ftp问题。

locateangel 2002-10-19 09:24:59
哪位前辈能指点一下,在vfp下能否实现从ftp上下载文件?
...全文
66 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
locateangel 2002-10-21
  • 打赏
  • 举报
回复
多谢二位前辈
philozz 2002-10-21
  • 打赏
  • 举报
回复
请参考:
1、在VFP菜单
工具-选项-控件 ActiveX控件 选上
microsoft Internet Transfer Control控件
2、链接可以,我又试了一次
http://fe2.gz.163.com/cgi/readsrh?b=VFP&t=27359&i=27359&al=5&n=0&l=40&back=2&st=0&kw=%CD%A8%D3%C3%BA%AF%CA%FD
locateangel 2002-10-21
  • 打赏
  • 举报
回复
还有问题:
第一个方法未成功实现,
第二个方法,我用的是vfp5,未找到相应控件,不知如何得到itc控件
第三个方法,连接无效。
还要麻烦前辈一下。
philozz 2002-10-19
  • 打赏
  • 举报
回复
方法一:使用fcreate/fwrite/fclose函数
*!**********************************
proc ftptest1
para p_usrname,p_password

m_ftpcp=fcreate(“ftpcp”,0)
if m_ftpcp=-1
wait wind "不能创建FTP连接!" nowait
return -1
endif

&& 假设远程FTP服务器的IP为192.168.0.1
&& FTP用户登录
m_ftpcommand=[open 10.168.0.1]+chr(13)+chr(10)+[p_usrname]+chr(13)+chr(10)+[[p_password]+chr(13)+chr(10)
if fwrite(m_ftpcp,m_ftpcommand)=0
wait wind "用户登录失败!" nowait
fclose(m_ftpcp)
return -1
endif

&& 将本地文件(c:\sqlnet.log)上传
m_ftpcommand=[bin]+chr(13)+chr(10)+[put c:\sqlnet.log] +chr(13)+chr(10)
if fwrite(m_ftpcp,m_ftpcommand)=0
wait wind "上传文件错误!" nowait
fclose(m_ftpcp)
return -1
endif

&& 将远程服务器上的文件(newmess.txt)下载
m_ftpcommand=[get newmess.txt]+chr(13)+chr(10)+[bye]+chr(13)+chr(10)
if fwrite(m_ftpcp,m_ftpcommand)=0
wait wind "下载文件错误!" nowait
fclose(m_ftpcp)
return -1
endif

&& 关闭FTP通信端口
fclose(m_ftpcp)
wait wind "文件成功传送!" nowait
return 0

方法二:使用microsoft Internet Transfer Control控件
(1)在form中加入microsoft Internet Transfer Control控件
假设名为olecontrol1
(2)
M_URLNAME="192.168.0.1"
thisform.olecontrol1.url=M_URLNAME
thisform.olecontrol1.username="anonymous"
thisform.olecontrol1.password="anonymous"
thisform.olecontrol1.openurl

&& 上传
m_sendFILE="sqlnet.log"
M_SENDCOMAND="SEND "+m_sendFILE+" "+m_sendFILE
thisform.olecontrol1.EXECUTE(M_URLNAME,M_SENDCOMMAND)

&& 下载
m_downfile="newmess.txt"
m_downcommand="GET "+m_downfile+" C:\TEMP\"+m_downfile
THISFORM.OLECONTROL1.EXECUTE(M_URLNAME,M_DOWNCOMMAND)

方法三:使用api
http://fe2.gz.163.com/cgi/readsrh?b=VFP&t=27359&i=27359&al=5&n=0&l=40&back=2&st=0&kw=%CD%A8%D3%C3%BA%AF%CA%FD
llzzllllz 2002-10-19
  • 打赏
  • 举报
回复
可以啊,在VFP中有个远程文件命令,可以试试。

2,749

社区成员

发帖
与我相关
我的任务
社区描述
VFP,是Microsoft公司推出的数据库开发软件,用它来开发数据库,既简单又方便。
社区管理员
  • VFP社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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