C# and Internet Explorer Automation

I have a web page that I am loading into Internet Explorer.  I am then trying to do a “Save As” to HTML via Automation.  I have been searching for a couple days and I can’t figure out how to do this.

I have been trying to do this with Microsoft.mshtml and SHDocVw in Visual Studio.
Any direction would be greatly appreciated.
Who is Participating?
rye004Connect With a Mentor Author Commented:
So If figured out, there is not good way to do this.  What I need up doing is calling the following:

WebBrowser. ShowSaveAsDialog();

Once the dialog shows, I do the following:

I realize this is lame, but it works.
Kalpesh ChhatralaSoftware ConsultantCommented:
you can try WebClient.

WebClient MyClient = new WebClient();
Byte[] MypageData = MyClient.DownloadData("http://kalpesh.biz");
string cDoc = Encoding.ASCII.GetString(MypageData);

Open in new window


you can try browser automation like below

            while (true)
                if (webBrowser1.ReadyState == WebBrowserReadyState.Complete)
            String cDoc = webBrowser1.Document.Body.InnerHtml;

Open in new window

you can save cDoc in html File.
rye004Author Commented:
Thank you kalpesh2804 for your response.
I did originally try “webBrowser1.Document.Body.InnerHtml”.
However it only gets the HTML from when the page was loaded.
With the “Save As” in IE it does a conversion process to save the HTML – which is what I am looking for.  If you take a website like “yahoo.com”, more content is added the more you scroll down.  If you do “InnerHtml”, it only gets the HTML that was loaded with the page.  However if you do a “Save As”, it does a conversion to view it later.
Hopefully this make sense.
rye004Author Commented:
No better reason was given.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.