Download File - VB6

前端 未结 7 1118
清酒与你
清酒与你 2020-11-30 09:15

Does anyone know how to download a file (without opening a webpage), and save it to a directory in Visual Basic 6.0?

相关标签:
7条回答
  • 2020-11-30 10:11

    Try this

    Sub DownloadFile(url, path)
    
       Dim objReq
       Dim objStream
    
       Set objReq = CreateObject("MSXML2.XMLHTTP")
       objReq.Open "GET", url, False
       objReq.send
    
       If objReq.Status = 200 Then
           Set objStream = CreateObject("ADODB.Stream")
           objStream.Open
           objStream.Type = 1
    
           objStream.Write objReq.ResponseBody
           objStream.Position = 0
    
           objStream.SaveToFile path, 2
           objStream.Close
           Set objStream = Nothing
       End If
    
       Set objReq = Nothing
    
    End Sub
    
    0 讨论(0)
提交回复
热议问题