我用INET控件写了一个FTP下载,请用如何用这个控件得到FTP空间里某一个文件的大小?我知道INET控件有个SIZE的属性可以得到大小,但是不知道具体怎么用。

解决方案 »

  1.   

    其实就是size命令,正确执行后,执行Inet1_StateChanged的Case 12中的过程
    使用getchunk接收
    Inet1.GetChunk(1024, 0) '0表示把数据作为字符串来检索,1表示把数据作为字节数组来检索附完整代码
    Dim OperationStyle As Integer
    Dim filesize As LongPrivate Sub Command1_Click()  Dim StrMsg As String
      Dim isbusy As Boolean
      
      Inet1.URL = "ftp://192.168.0.1/"
      Inet1.Protocol = icFTP
      Inet1.UserName = ""
      Inet1.Password = ""
      
      StrMsg = "Dir"
      Inet1.Execute , StrMsg
      
    End SubPrivate Sub Command3_Click()
    OperationStyle = 2
    Inet1.Execute , "size wq.rar"
    End SubPrivate Sub Inet1_StateChanged(ByVal State As Integer)
    Select Case State
     Case 1
        Text1.Text = "is looking"
    Case 2
        Text1.Text = "success finding "
    Case 3
      Text1.Text = "is connecting"
    Case 4
      Text1.Text = "success connected"
    Case 5
      Text1.Text = "is sending request"
    Case 6
      Text1.Text = "sucess sending"
    Case 7
      Text1.Text = "is receiving"
    Case 8
      Text1.Text = "success receive"
    Case 9
      Text1.Text = "is disconnecting"
    Case 10
      Text1.Text = "success disconnect"
    Case 11
      Text1.Text = "is error"
    Case 12 'icResponseCompleted
      Text1.Text = "success receive data"
      Select Case OperationStyle
      Case 2
          filesize = Inet1.GetChunk(1024, 0)
            MsgBox CStr(filesize)
      Case Else
      End Select
    End Select
    End Sub
      

  2.   

    我这边没有环境,我架设不了FTP
    你这个问题我转给online和大斑竹过大斑竹也没有环境因为他也在外地出差,online现在已经答你的了对于问题,我解决不了的,我一般会转给可能能够解答的斑竹的:)
      

  3.   

    Inet1.Execute , StrMsg这一行出错,不能连接远程主机
      

  4.   

    Inet1.URL = "ftp://192.168.0.1/"
      Inet1.Protocol = icFTP
      Inet1.UserName = ""
      Inet1.Password = ""
    这个换成你可以访问的站点,我在本机安装了ftp环境