简体   繁体   English

从C#Windows窗体中的URL下载文件

[英]Downloading a file from url in c# windows forms

I have url like this 我有这样的网址

http://domainname.com/view/downloadfile?uname= 'ddd'&id=4 http://domainname.com/view/downloadfile?uname='ddd'&id = 4

if we type the above url (not exactly the same ) in browser address bar it prompts open/save file dialog 如果我们在浏览器地址栏中输入上述网址(不完全相同),则会提示打开/保存文件对话框

my requirement is in button click without open/save dialog i need to download the file to my local disk location 我的要求是单击按钮时没有打开/保存对话框,我需要将文件下载到本地磁盘位置

Actually am working with webbrowser control .button is outside the webbrowser control 实际上正在使用webbrowser控件。button在webbrowser控件之外

You could use the WebClient.DownloadFile method. 您可以使用WebClient.DownloadFile方法。 Or if you don't want to save the file on the disk but manipulate it in memory you could use the WebClient.DownloadData method. 或者,如果您不想将文件保存在磁盘上,而是在内存中进行操作,则可以使用WebClient.DownloadData方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM