从 URL 代码 VB.NET 下载文件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/36856115/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-08 21:12:22 来源:igfitidea点击:
Download File From URL Code VB.NET
提问by Christian Yonathan S.
i would like ask about, how to download file from url by code vb.net?
example : Example Linkbefore download the file, user MUSTinput Username and Password? how can i do that? any reference or link? thanks!
我想问一下,如何通过代码vb.net从url下载文件?
示例:
下载文件之前的示例链接,用户必须输入用户名和密码?我怎样才能做到这一点?任何参考或链接?谢谢!
回答by Claudius
Use System.Net.WebClient.DownloadFile
用 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