我在网上查了下载的方法,有很多种,试了这个能下载到本地,但是文件的字节是0,请高手帮我看看是什么问题呢。
(困惑好几天了)
代码如下
Function downFile(Inet1 As Inet, url As String, dest As String) As Boolean
On Error GoTo er1
        Dim bytes() As Byte
        bytes() = Inet1.OpenURL(url, icByteArray)
        Dim tempS
        Open dest For Binary Access Write As #2
                Put #2, , bytes()
        Close #2
        downFile = True
        Exit Function
er1:
MsgBox Err.Description
downFile = False
End FunctionPrivate Sub Command1_Click()
downFile Inet1, "ftp://gfgl:[email protected]/00000005GF01.jpg", "C:\TEMP\1.jpg"
End Sub

解决方案 »

  1.   

    可能是你用户名gfgl密码12345不对
    先放在浏览器地址栏里面试试
      

  2.   

    FtpGetFile  能不能给个实例呀
      

  3.   

    你重新下载一个FTP试试呢?我是在这上面下载的:http://www.evget.com/zh-CN/products/category/398_264-0-0-0/default.aspx
      

  4.   

    楼上的FTP是for .net的
    我用的是VB
      

  5.   

    我用下面的代码也不行,连文件都不创建了
    Inet1.Execute "ftp://gfgl:[email protected]", "GET B564801.jpg   C:\TEMP\B564801.jpg"
    right1 = Inet1.StillExecuting
    Do While right1
        right1 = Inet1.StillExecuting
        DoEvents
    Loop
    这个用户对文件的权限是读写删
      

  6.   

    我自己程序用的代码,绝对好用
    Private Function GetFtpUpdateFile() As Boolean
        
        '获取FTP中的更新文件
         Dim lngInet         As Long
        Dim lngInetConn     As Long
        Dim lngRet          As Long
        lngInet = 0
        lngInetConn = 0
        lngRet = 0
        
        lngInet = InternetOpen(vbNullString, 1, vbNullString, vbNullString, 0&)
        If lngInet Then
        
            lngInetConn = InternetConnect(lngInet, 服务器IP, 端口, 用户名, 密码, 1, 0, 0)
            If lngInetConn Then
                lngRet = FtpGetFile(lngInetConn, 文件名, 0, 0, 1, 0)
                InternetCloseHandle lngInetConn
            End If
            
            InternetCloseHandle lngInet
        End If
        
        If lngRet = 0 Then
            GetFtpUpdateFile = False
            Exit Function
        End If    。。
      

  7.   

    麻烦楼上的,问一下“端口”是什么呢,“文件名”是源的还是目的的,文件最后存在本地的什么位置了呀,
    另外这是一个自定义的函数吧,在按钮的单击方法中是不是直接用就可以了GetFtpUpdateFile() 
    这里面是不是还有几个是自定义的函数吧