当前位置:编程学习 > VB >>

vb如何获取FTP文件的总大小?

例如:客户端A 通过FTP上传文件file1.rar给服务器,在服务器端软件每隔一段时间(比如1s)检测文件file1.rar的大小是不断变化的,用vb如何获取上传文件file1.rar的总大小?

'Example Name:Get File Size
' Example by AKriLium-Death (bumpybl2@hotmail.com)
' Visit his site at http://rift.zeloop.com
'This project needs
' -a Command Button (Command1)
' -a CommonDialog (CommonDialog1)
' -a Label (Label1)
Private Const OF_READ = &H0&
Private Declare Function lOpen Lib "kernel32" Alias "_lopen" (ByVal lpPathName As String, ByVal iReadWrite As Long) As Long
Private Declare Function lclose Lib "kernel32" Alias "_lclose" (ByVal hFile As Long) As Long
Private Declare Function GetFileSize Lib "kernel32" (ByVal hFile As Long, lpFileSizeHigh As Long) As Long
Dim lpFSHigh As Long
Public Sub GetInfoF(FilePath As String)
    Dim Pointer As Long, sizeofthefile As Long
    Pointer = lOpen(FilePath, OF_READ)
    'size of the file
    sizeofthefile = GetFileSize(Pointer, lpFSHigh)
    Label1.Caption = sizeofthefile & " bytes"
    lclose Pointer
End Sub
Private Sub command1_Click()
    CommonDialog1.ShowOpen
    GetInfoF CommonDialog1.filename
End Sub
Private Sub Form_Load()
    With CommonDialog1
        .DialogTitle = "Select a file"
        .Filter = "All the files|*.*"
    End With
    Command1.Caption = "Select a file"
End Sub


补充:VB ,  网络编程
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,