现在是该设置控件属性的时候了:
将url属性设置为ftp服务器的url。
将用户名(username)和密码(password)的属性设置为合法的用户id和密码,这也是ftp所要用到的。(如果你将这些属性留成空白,那么用户名属性就会被设置为匿名(anonymous),而密码属性会被设置为一个缺省的密码。)
将协议(protocol)属性设置为icftp,这是访问ftp所需要的。设置一下requesttimeout,以防止在服务器没有相应的时候控件挂起。例如:
with .net1
.url = "ftp://myftpserver"
.username = "myusername"
.password = "mypassword"
.protocol = icftp
.requesttimeout = 120
end with
要进行get或者put操作,就要调用execute方法。第一个自变量是可选的,它允许你指定url。第二个自变量能够让你指定要进行的操作。当get操作被调用的时候,你必须传递被请求文件的名称和要创建的本地文件名。当put操作被调用的时候,要被上传的文件就会被指定,然后就在ftp服务器上创建这个文件。
call .net1.execute(, "get ftpfile.txt c:\temp\ftpfile.txt")
call .net1.execute(, "put c:\temp\ftpfile.txt ftpfile2.txt")
execute方法是异步工作的,所以你可以使用statechanged事件来监控这项操作的进展情况。state自变量会是一个stateconstant。你可以使用对象浏览器(object browser)或者在线帮助(online help)来查看state所有合法的值。
private sub .net1_statechanged(byvalstate as integer)
debug.printstate
end sub
如果state等于icerror,那么你可以通过responsecode和responseinfo属性来获取错误信息。
debug.print .net1.responsecode
debug.print .net1.responseinfo
Java Asp PHP .Net XML C/C++ CGI VB Jsp J2ee J2se J2me EJB Servlet Tomcat Resin Struts Weblogic Eclipse ANT GUI JMS Web servise IDEA Webphere Hibernate Spring Jboss Applet Swing Socket Javamail Perl Ajax P2P 安全 模式 框架 测试 开源 游戏
Windows XP Windows 2000 Windows 2003 Windows Me Windows 9.x Linux UNIX 注册表 操作系统 服务器 应用服务器