使用webbrowser下载文件. [英] Using webbrowser down load files.

查看:81
本文介绍了使用webbrowser下载文件.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我需要使用Webbrowser控件下载文件[XML/PDF].在超链接中,他们编写了JavaScript制成POST方法,并且正在提交表单.所以我不能采取绝对的文件路径来使用"Webclient"下载该文件.每次询问打开/保存对话框.我想避免同样的事情.

请帮助我

在此先感谢
Bell


I need to download the files[XML/PDF] using webbrowser control. In hyperlink they have written javascript to make POST method and they are submitting the form. so i couldnt take absolute file path to download teh file using "Webclient". Every time its asking the open/save dialog box. i want to avoid the same.

Kindly help me out

Thanks in advance
Bell

推荐答案

使用System.Net.Webclient,您可以轻松地将文件下载到Web URL上,确保文件路径相对于Web URL是相对的.如果exam​​ple.jpg托管在www.example.com的根目录中,则使用like,

Using System.Net.Webclient, you can easily download the file on the Web url, make sure that the file path is relative to the web url e.g. If the example.jpg is hosted in the root of www.example.com then use like,

WebClient wc = new WebClient();
wc.DownloadFile("http://www.example.com/example.jpg", @"C:\example.jpg");



您需要传递本地物理路径,以避免打开/保存文件对话框.

此处



You need to pass the local physical path to avoid open/save file dialog.

Find more info here


这篇关于使用webbrowser下载文件.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆