saving the contents of axWebBrowser1 to a htm file ?

  • Thread starter Thread starter MrXs
  • Start date Start date
M

MrXs

hi

how do i save the contents of a axWebBrowser1 to a htm file ?

i have a webpage loaded and would like to save it to my harddrive.

also how do i open the file from my harddrive to open in the
axWebBrowser1 box ?

Thanks MrXs
 
Try this

1 .Define HTMLDocumentClass object

private mshtml.HTMLDocumentClass pHTMLDoc;

2. In the document complete event do this

private void myBrowser_DocumentComplete(object sender,
AxSHDocVw.DWebBrowserEvents2_DocumentCompleteEvent e)
{
pHTMLDoc= (HTMLDocumentClass)DesignBrowser.Document;
}

3. To save

pHTMLDoc.execCommand ("SaveAs", false, @"c:\test.html");

4. To open html page navigate browser

string htmlfile =@c:\test.hml";
object oEmpty = null;
object oUrl = htmlfile;

myBrowser.Navigate ( ref oUrl, ref oEmpty, ref oEmpty, ref oEmpty, ref
oEmpty );
 
thanks shakir, that put me on the right track ;)

i used the followng code



private void buttonItem11_Click(object sender, System.EventArgs
e)
{
object oEmpty = null;
object oURL = "c:/test.htm";
axWebBrowser1.Navigate2(ref oURL, ref oEmpty, ref oEmpty,
ref oEmpty, ref oEmpty);
}



but i require opening a page i select that is saved to my hd ( browse
the file then select and load ) each time i will select a different
page / htm file to load so should i use the browse dialog ?

thanks :D
 
Yes, use the OpenfileDialog and receive the file name from user. Then pass
it to Navigate2 method.
 
Back
Top