vb.net 如何使用 Visual Basic .NET 从网站下载 PDF 并存储在 %appdata%
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13539787/
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
How to download PDF from website and store in %appdata% with Visual Basic .NET
提问by James S
I have a PDF file hosted on a website. I would like my VB.NET program to retrieve the file/download it and store it somewhere in %appdata%. This could be in a folder of it's own like %appdata%/my_programif you want. How do I achieve this in my VB.NET program?
Thanks.
我在网站上托管了一个 PDF 文件。我希望我的 VB.NET 程序检索/下载文件并将其存储在%appdata%. %appdata%/my_program如果您愿意,这可以在它自己的文件夹中。我如何在我的 VB.NET 程序中实现这一点?谢谢。
回答by Mehdi Valikhani
You can use WebClient.DownloadFile(Url,LocalPath)for downloading your PDF file and saving in a local path on your PC. The class is in System.Net Assembly.
您可以WebClient.DownloadFile(Url,LocalPath)用于下载 PDF 文件并将其保存在 PC 上的本地路径中。班级在System.Net Assembly。
回答by Jet
Use this to download file:
使用它来下载文件:
Dim WC As New System.Net.WebClient
WC.DownloadFile(URL, FileName)
or
或者
My.Computer.Network.DownloadFile(URL, FileName)
To save it in the %appdata% just use :
要将其保存在 %appdata% 中,只需使用:
My.Computer.FileSystem.SpecialDirectories.AllUsersApplicationData
or
或者
My.Computer.FileSystem.SpecialDirectories.CurrentUserApplicationData

