Hi,
I've an application in which I need to download, every time it starts (on form_laod), a file from a url.
I know the name of the file, always the same; i need to know what kind of controls and statements I should use to make this,...have you any tips?
I've noticed that there are several question like this in Vb forums, and no-one with a resolutive reply. Maybe too simple question.
Otherwise, for future threads like this , the MSDN provides this code:
'this if you have a firewall
With Inet1
.URL = "your url"
.UserName = "username"
.Password = "password"
.Execute , "GET "
.Execute , "CLOSE" ' Close the connection.
End With
Dim intFile As Integer ' FreeFile variable
intFile = FreeFile()
Open "path & name of file destination" For Output As #intFile
Write #intFile, Inet1.OpenURL("your URL"
Close #intFile
End Sub
Private Sub Inet1_StateChanged(ByVal State As Integer)
Dim vtData As Variant ' Data variable.
Select Case State
' ... Other cases not shown.
Case icResponseCompleted ' 12
' Open a file to write to.
Open txtOperation For Binary Access _
Write As #intFile
' Get the first chunk. NOTE: specify a Byte
' array (icByteArray) to retrieve a binary file.
vtData = Inet1.GetChunk(1024, icString)
Do While LenB(vtData) > 0
Put #intFile, , vtData
' Get next chunk.
vtData = Inet1.GetChunk(1024, icString)
Loop
Put #intFile, , vtData
Close #intFile
End Select
End Sub
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.