毁于随的专栏

业精于勤荒于嬉,形成于思毁于随!

Inet1 按字节下载文件!!

因为用到了 就抄了过来 .

程序文件升级时,很有用的 :)

 

http://www.cndevx.com/club/printpage.asp?BoardID=30&ID=47949

文件地址

Private Sub Command1_Click()
Inet1.Execute , "Get"
End Sub

Private Sub Form_Load()
Inet1.URL = http://1122.122.221/aaa.exe

End Sub

Private Sub Form_Unload(Cancel As Integer)
Inet1.Execute , "QUIT"
End Sub

Private Sub Inet1_StateChanged(ByVal State As Integer)
    Dim aa As Variant
    Dim vtData()   As Byte   '数据变量。

    Dim TotalLength As Variant
    If State = 12 Then
   
        TotalLength = Val(Inet1.GetHeader("Content-length"))
        psb.Max = TotalLength
        Open "d:/cat.exe" For Binary Access Write As #1
        vtData = Inet1.GetChunk(1024, icByteArray)
        Do While UBound(vtData) > 0
        DoEvents
            Put #1, , vtData
            If (psb.Value + 1024) > psb.Max Then
                psb.Value = psb.Max
            Else
                            
                psb.Value = psb.Value + 1024
            End If
            vtData = Inet1.GetChunk(1024, icByteArray)
                            
        Loop
        Put #1, , vtData
        Close #1
        MsgBox "下载完毕"
    End If

End Sub

阅读更多
个人分类: VB编程经验
想对作者说点什么? 我来说一句

VB通过inet上传下载文件

2010年11月25日 8KB 下载

没有更多推荐了,返回首页

加入CSDN,享受更精准的内容推荐,与500万程序员共同成长!
关闭
关闭