在webbrowser文件下载对话框中自动选择保存选项 [英] Automatically select save option in webbrowser file download dialog box
问题描述
大家好
如果这是在错误的论坛,请先道歉。
我有一个Windows窗体应用程序(Vb .net)通过Web浏览器控件连接到站点。问题是我需要导航到特定部分并下载从回发生成的pdf文件。我想自动执行此过程或绕过
文件下载对话框并将文件直接保存到本地驱动器。
问题
该链接不是标准网址。该站点使用回发脚本来获取所需的文件,然后显示文件下载对话框。例如。当你点击链接(javascript:postback)时,会自动加载文件下载对话框。
我尝试了什么(虽然我可能做错了)
- 我尝试过使用my.computer.network .... 但我似乎无法从脚本中获取文件。
- 我尝试过使用webclient.downloadfile ....功能,但因为它不是一个网址我也被卡住了。
如上所述,我可以访问该文件,但我想绕过保存选项并自动存储文件在预定义的位置。任何帮助将不胜感激。
您好DaveGMSProject,
我不是很熟悉JavaScript。
但我认为在不知道文件的情况下保存文件有点困难。这是一个讨论它的主题:
http://social.msdn.microsoft.com/Forums/en-US/winforms/thread/710e14d1-9e5a-4650-a732-bc5825ce4472
也许你需要实现自己的下载管理器。以下是对此的建议:
Hi All
First off my apologies if this is in the wrong forum.
I have a windows form app (Vb.net) which connects to a site via a web browser control. The problem is I need to navigate to a specific section and download a pdf file which is generated from a postback. I would like to either automate this process or bypass the file download dialog and save the file directly to a local drive.
Problem
The link is not a standard url. The site uses a postback script to get the file needed which then displays the file download dialog box. E.g. When you click on the link (javascript: postback) the file download dialog box is automatically loaded.
What I’ve tried (although I could be doing something wrong)
- I’ve tried using my.computer.network…. but I cant seem to get the file from the script.
- I’ve tried using the webclient.downloadfile…. function but because it’s not a url I’m stuck as well.
As stated I can get to the file but I want to bypass the save options and automatically store the file in a predefined location. Any help would be much appreciated.
Hi DaveGMSProject,
I'm not very familiar with JavaScript.
But I think it is a little difficult for us to save the file without knowing its url. This is a thread talking about it:
http://social.msdn.microsoft.com/Forums/en-US/winforms/thread/710e14d1-9e5a-4650-a732-bc5825ce4472
Maybe you need to implement your own download manager. Here is a suggestion about it:
这篇关于在webbrowser文件下载对话框中自动选择保存选项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!