6
votes

i would like ask about, how to download file from url by code vb.net?
example : Example Link before download the file, user MUST input Username and Password? how can i do that? any reference or link? thanks!

1
You can use a WebClient, set the Credentials property and call the DownloadFile method. - jmcilhinney
thank you, please any references or link please @jmcilhinney ... - Christian Yonathan S.
How about the Help menu in VS? - jmcilhinney
The example link in your question leads to a 404 error. Please check it out. - Xlam

1 Answers

12
votes

Use System.Net.WebClient.DownloadFile

Dim remoteUri As String = "http://belajar123.com/materi.zip"
Dim fileName As String = "materi.zip"
Dim password As String = "..."
Dim username As String = "..."

Using client as New WebClient()

    client.Credentials = New NetworkCredential(username, password)
    client.DownloadFile(remoteUri, fileName)
End Using