简体   繁体   English

以编程方式保存MHT而不进行对话

[英]Programmatically save an MHT without dialog

Is it possible to save a file of any type bypassing the 'save as' dialog? 是否可以绕过“另存为”对话框保存任何类型的文件? using the WebBrowser Class 使用WebBrowser类

WebBrowser.ShowSaveAsDialog();

Is the loaded content in a WebBrowser control serializable so it can be saved and retrieved (for redisplay)? WebBrowser控件中加载的内容是否可序列化,以便保存和检索(重新显示)?

Given that you have full access to the DOM and can therefore read any contents that the WebBrowser is displaying the answer must be yes . 鉴于您具有对DOM的完全访问权限,因此可以读取WebBrowser正在显示的任何内容,答案必须为yes

  • Using the tree of DOM nodes read the contents of the WebBrowser into the C# world 使用DOM节点树将WebBrowser的内容读入C#世界
  • Write to the file using normal .NET file access 使用普通的.NET文件访问权限写入文件

However if you just wish to download a webpage and save it to disk there are better ways then using the WebBrowser control, have a look at the WebClient class 但是,如果您只是想下载一个网页并将其保存到磁盘,那么有更好的方法然后使用WebBrowser控件,看一下WebClient

I see this is an old question, but I'm just going to update with a possible alternative. 我认为这是一个老问题,但我只想更新一个可能的替代方案。

Please take a look in this CodeProject article . 请查看此CodeProject文章

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

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