0

The WebBrowser control has a method named ShowSaveAsDialog() which can save a loaded document into a file. I want to find out the path of the saved file and open it. How can I find such a path or an alternative way to save an html file loaded by WebBrowser control.

Ahmad
  • 6,124
  • 6
  • 49
  • 90
  • Do you need to save the document images and css and scripts in separate files and update the addresses in document to use local files? Or maybe you only need to save exact content of document in a single file? – Reza Aghaei Dec 26 '15 at 10:07
  • @RezaAghaei I need to save everything so that the local file appears like the original page. – Ahmad Dec 26 '15 at 12:53

1 Answers1

1

It seems you want to save everything to a web archive (.mht) file. I can't see that anyone has got that working via the WebBrowser control.

However, there are alternatives for doing this programatically. Jeff Atwood posted an article on CodeProject: Convert any URL to a MHTML archive using native .NET code but it's in VB.NET. Incidentally, Jeff is one of the co-founders of this site and is Stack Overflow Valued Associate #00001!

Someone has kindly ported Jeff's code to C# and that can be found on Google Code here: url2mhtml

Also see this question: generate .mht file programmatically

Community
  • 1
  • 1
davmos
  • 8,724
  • 4
  • 36
  • 41