用ftp手工上传文件没有什么可以说的,但我们往往需要通过程序来控制这一过程,即通过asp.net来实现这一目的.如果ftp软件具备可二次开发的接口就好了.经典的cuteftp pro就具有这样的功能。
安装完cuteftp pro 7后,会生成一个文件叫ftpte(ftp传输引擎),ftpte提供了很多属性和方法,能够方便地通过编程来实现大文件的上传,包括文件过滤、目录和文件检测、文件删除、改名、传输启动和停止以及状态查看等等。
下面是实例:
连接ftp服务器:
set mysite = createobject("cuteftppro.teconnection")
mysite.protocol = "ftp"
mysite.host = "ftp.cuteftp.net"
mysite.login = "username"
mysite.password = "password"
mysite.connect
上传文件:
set mysite = createobject("cuteftppro.teconnection")
‘specify user, pass, host, and connect as normal...
mysite.connect ‘recommended: call connect first
mysite.remotefolder = "temp"
mysite.localfolder = "c:/123"
‘using relative path, all files in folder 123 are uploaded to the folder temp off the current folder on the server.
mysite.upload "*.*"
下载文件:
set mysite = createobject("cuteftppro.teconnection")
‘specify user, pass, host, and connect as normal...
mysite.connect ‘recommended: call connect first
‘next line changes to a predetermined folder so you can use a relative path in the download method
mysite.remotefolder = "/c:/inetpub/ftproot/temp/temp/"
msgbox (mysite.remotefolder) 'display current remote folder
mysite.download "agent.ini", "c:/temp/agent1.ini"
'now verify downloaded ok
if cbool(mysite.localexists ("c:/temp/agent1.ini")) then
msgbox "file downloaded ok."
end if
从实验的情况看,ftpte在c/s模式下能很好的支持各项功能,在b/s模式下会找不到组件,可能与没有注册有关。
通过利用ftpte,可能编程实现远程文件定时或不定时同步等诸多功能,从而实现非手工方式的文件传输。
新闻热点
疑难解答