【问题标题】:Download File From URL Code VB.NET从 URL 代码 VB.NET 下载文件
【发布时间】:2016-04-26 05:39:40
【问题描述】:

我想问一下,如何通过代码vb.net从url下载文件?
例如:Example Link 在下载文件之前,用户必须输入用户名和密码?我怎样才能做到这一点?任何参考或链接?谢谢!

【问题讨论】:

  • 您可以使用WebClient,设置Credentials 属性并调用DownloadFile 方法。
  • 谢谢,请提供任何参考资料或链接@jmcilhinney ...
  • VS中的帮助菜单怎么样?
  • 您问题中的示例链接导致 404 错误。请检查一下。

标签: vb.net file download


【解决方案1】:

使用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

【讨论】:

    猜你喜欢
    • 2012-10-16
    • 1970-01-01
    • 2012-05-14
    • 1970-01-01
    • 1970-01-01
    • 2016-07-23
    • 2012-08-06
    • 1970-01-01
    相关资源
    最近更新 更多