我想问一下,如何通过代码vb.net从url下载文件?
示例:Example Link
在下载文件之前,用户必须输入用户名和密码?我怎样才能做到这一点?任何参考或链接?谢谢!
答案 0 :(得分:8)
使用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