简体   繁体   English

没有保存对话框的下载文件

[英]Download file without save dialog

In VB.NET I need to download a file from the web but without the save dialog box appearing. 在VB.NET中,我需要从Web下载文件,但没有出现“保存”对话框。 I am using a .net web browser control. 我正在使用.net Web浏览器控件。

The catch here is I do not know the url of the file that has to be downloaded. 这里的问题是我不知道必须下载的文件的URL。 It is getting passed by the website. 网站正在通过它。

For example: If I pass the following url in browser " http://www.ncdex.com/MarketDataAction_bhavCopySubmit.action " then webbrowser file download event gets fired and a save file dialog box appears. 例如:如果我在浏览器“ http://www.ncdex.com/MarketDataAction_bhavCopySubmit.action ”中传递以下网址,则会触发webbrowser文件下载事件,并出现一个保存文件对话框。 After this I have to manually click on save and then save the file to a specific path. 之后,我必须手动单击“保存”,然后将文件保存到特定路径。

I want to automate this process which means file gets saved automatically to the path I want. 我想自动化这个过程,这意味着文件会自动保存到我想要的路径。

Can this be done ? 能做到吗? Otherwise I will then have to use sendkeys to manage the dialog box which may not be easy. 否则,我将不得不使用sendkey来管理对话框,这可能并不容易。

If you're not opposed to using a different class than the WebBrowser control for this particular functionality you can leverage the WebClient class to make this easy: 如果您不反对使用与WebBrowser控件不同的类来实现此特定功能,则可以利用WebClient类来简化此工作:

    Dim strURL As String = "http://www.ncdex.com/MarketDataAction_bhavCopySubmit.action"

    Dim strFileLocation As String = "C:\SomeLocation\SomeFileName.SomeExtension"

    Dim objWebClient As New System.Net.WebClient()

    System.IO.File.WriteAllBytes(strFileLocation, objWebClient.DownloadData(strURL))

暂无
暂无

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

相关问题 从显示另存为对话框的服务器下载文件 - Download file from server showing save as dialog .NET在下载时提示“另存为”对话框 - .NET Prompt a Save As dialog on download 如何在没有打开/保存对话框的情况下播放Telerik RadCaptcha .wav文件 - How to play Telerik RadCaptcha .wav file without open/save dialog 将 FixedDocument/XPS 打印到 PDF 而不显示文件保存对话框 - Print FixedDocument/XPS to PDF without showing file save dialog 以编程方式保存MHT而不进行对话 - Programmatically save an MHT without dialog 如何在不使用保存文件对话框的情况下使用内存流保存图像 - How to using memory stream to save image without using save file dialog 如何在不弹出“保存文件”对话框的情况下将Microsoft Project文件(mpp)导出到tif(tiff)? - How to export a Microsoft Project file (mpp) to tif (tiff) without popup save file dialog? 下载到文件并保存到字节数组 - Download to file and save to byte array 从一个流中下载文件,然后将其保存为zip格式,而无需将所有数据存储在内存中 - Download file from one stream and save it to zip in another stream without putting all data in memory 我想弹出我自己的对话框(在服务器上保存文件而不询问目标路径位置)而不是adobe的另存为对话框 - i want to pop up my own dialog(which save file on server without asking the target path location) instead of adobe's save as dialog
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM