我现在做一个小程序,需要读取ftp服务器上的某个文件,如何判断这个文件是否存在呢?好像需要读取权限的用户名和密码的,这个我都有,但是就是不知道该怎么实现?

解决方案 »

  1.   

    cd remote-dir:进入远程主机目录。dir[remote-dir][local-file]:显示远程主机目录,并将结果存入本地文件local-file。
      

  2.   


    <a href="http://blog.csdn.net/z_wenqian/archive/2011/04/28/6368901.aspx">http://blog.csdn.net/z_wenqian/archive/2011/04/28/6368901.aspx</a>
      

  3.   

    可以用FileExists 方法啊。可以先登录上FTP再FileExists(admin/admin.asp)就行了啊
      

  4.   

      inet1.URL=ftp://username:password@hostname/document   
      inet1.Protocol=2-icFTP   
      inet1.RemoteHost=hostname   
      inet1.RemotePort=21   
      inet1.Username=username   
      inet1.   Password=password 
      

  5.   

      If (fso.FileExists(filespec)) Then
        msg = filespec & " 存在。"
      Else
        msg = filespec & " 不存在。"
      End If
      

  6.   

    我这样写怎么还是不行呢,麻烦帮我看一下,谢谢!    Inet1.URL = "ftp://username:[email protected]"
        Inet1.Protocol = 2
        Inet1.RemoteHost = "192.168.0.3"
        Inet1.RemotePort = 21
        Inet1.UserName = "123"
        Inet1.Password = "123"
        If fso.FileExists("ftp://192.168.0.2/abc.txt") Then 
        Open "ftp://192.168.0.2/abc.txt" For Input As #7 '打开文件
        End If
      

  7.   

    其实我也是新手。要是能用IE打开该FTP你可以根据IE返回的错误号也能确定文件是否存在。
    比如你打开“http://www.csdn.net/12345678.txt”返回404就表示文件不存在
      

  8.   

    你好,我们还是加q聊一下吧,我的:1459547489,谢谢!
    我用的是自己的主机当的虚拟服务器,我确定那个文件是存在的,但是在VB程序里面就会报错。