【问题标题】:how to extract recent downloaded file path from internetexplorer object in C#如何从 C# 中的 internetexplorer 对象中提取最近下载的文件路径
【发布时间】:2013-10-14 10:43:29
【问题描述】:

我目前正在制作一个程序,它会自动从 gerrit 下载文件。 但是我试图使程序自动完整,但无法找到如何使 ie 对象自动下载文件而不按下载文件弹出窗口。 我尝试了很多方法来实现它,但无法解决它。 所以我只是放弃了这种方式并选择制作用户应该手动按下下载按钮的程序。

现在我遇到了新问题。

这个程序应该打开新下载的文件,不知道如何从ie对象中获取新下载的文件路径。

点击ie中的下载文件按钮后, 如何从 C# 中的 ie 对象获取最近下载的文件路径? 谁能告诉我怎么做?

【问题讨论】:

标签: c# internet-explorer download filepath


【解决方案1】:

您可以使用WebClient 下载文件并完全跳过IE

例子:

using (WebClient webClient = new WebClient())
{
    webClient.DownloadFile("http://myFile.com", "C:\\Downloads\MyFile.iso");
}

或异步 (.NET4.5)

using (WebClient webClient = new WebClient())
{
   await webClient.DownloadFileTaskAsync("http://myFile.com", "C:\\Downloads\\MyFile.iso");
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-03-02
    • 2015-01-29
    • 2013-08-25
    • 2013-06-08
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多