【问题标题】:Download a file in VB.NET without Internet Explorer在没有 Internet Explorer 的情况下在 VB.NET 中下载文件
【发布时间】:2021-03-05 03:39:54
【问题描述】:

我的问题可能听起来很奇怪,但我想知道如何在没有 Internet Explorer 的情况下从 VB.NET 下载文件。

我知道:

My.Computer.Network.DownloadFile(
    "http://www.cohowinery.com/downloads/WineList.txt",
    "C:\Documents and Settings\All Users\Documents\WineList.txt")

但当他尝试时,他使用 Internet Explorer 下载它。我下载文件的站点与 Internet Explorer 不兼容。所以它不会下载。

如何使用其他网络浏览器(例如 Firefox)下载它?

谢谢!

【问题讨论】:

  • 使用WebClient 类。那么你没有使用任何网络浏览器。我不知道您使用 IE 的代码,但我实际上并没有使用该方法,所以它永远不会出现。不,我不会提供“示例”。已经有很多负载了,您还应该阅读该类的文档。

标签: windows vb.net visual-studio


【解决方案1】:

检查'WebClient.DownloadFile' method。

您可能需要的一个简单示例:

    Dim client As New WebClient()
    client.Credentials = New NetworkCredential("UserName", "Password") ' If need be.
    client.DownloadFile(url, fileName)

【讨论】:

    猜你喜欢
    • 2016-12-10
    • 1970-01-01
    • 2013-07-26
    • 2010-09-24
    • 2010-09-09
    • 1970-01-01
    • 2022-01-10
    • 2012-05-29
    相关资源
    最近更新 更多