如何取得ftp server上的文件的大小?

解决方案 »

  1.   

    你用什么连接服务器,我说一种用Inet控件的方法
    加入Inet控件Name为ITC
    Private Sub cmdSize_Click()
    'If the itc is ready then get the size
    If ITCReady(True) Then
        RecievingSize = True
        ITC.Execute , "SIZE " & Chr(34) & lstRemoteFile.Text & Chr(34)
        Do Until ITCReady(False)
                DoEvents: DoEvents: DoEvents: DoEvents
        Loop
        lblStatus = "Connected"
        RecievingSize = False
    End If
    End SubPrivate Function ITCReady(ShowMessage As Boolean)
    'Check the state of itc, if it is not executing return true
    If ITC.StillExecuting Then
        ITCReady = False
        If ShowMessage Then
            MsgBox "Please wait.  FTP is still executing", vbInformation + vbOKOnly, "Busy"
        End If
    Else
        ITCReady = True
    End If
    End Function
    ==天下本无事,庸人自扰之==
    得意淡然,失意泰然
    [email protected]
      

  2.   

    ITC.Execute , "SIZE " & Chr(34) & lstRemoteFile.Text & Chr(34)这句是取得ftp上的文件的大小嘛?我用了不可以的嘛(直接在ftp上用命令打进去的,不可以的)
      

  3.   

    如果是用API
    使用 FtpFindFirstFile,InternetFindNextFile(hFile, udtWFD)获取文件信息
    Dim hFile As Long, udtWFD As WIN32_FIND_DATA
        hFile = FtpFindFirstFile(server, adr, udtWFD, INTERNET_FLAG_RELOAD Or INTERNET_FLAG_NO_CACHE_WRITE, 0&)文件的尺寸就是
    Format((udtWFD.nFileSizeLow / 1024), "### ### ###.##")==天下本无事,庸人自扰之==
    得意淡然,失意泰然
    [email protected]
      

  4.   

    我是用Inet控件的我知道ftp上的文件名现在要解决的问题是:如何让我知道这个文件的大小,并存储在变量中
      

  5.   

    Inet1.Execute , "SIZE " & """" & FileName & """"
        FileSize = frmTmp.Inet1.GetChunk(1024)