2016-04-26 101 views
1

我想問一下,如何通過代碼vb.net從url下載文件?
例如:Example Link 下載文件之前,用戶必須輸入用戶名和密碼?我怎樣才能做到這一點?任何參考或鏈接?謝謝!從URL代碼VB.NET下載文件

+1

可以使用'WebClient',設置'Credentials'屬性和調用'DownloadFile'方法。 – jmcilhinney

+0

謝謝,請任何參考或鏈接請@jmcilhinney ... –

+0

如何在VS中的幫助菜單? – jmcilhinney

回答

4

使用System.Net.WebClient.DownloadFile

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

Using (var client = new WebClient()) 

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

謝謝,我真的很感激。 @Claudius –

+0

如果它的作品標記爲答案/ upvote – Claudius

+0

hehehe,似乎我忘記了這一點。 謝謝你提醒我。 hehehe –