Does anyone (please) know how to do this? I thought that there would be an easy way to achieve this but can't find anything about saving the contents of WebBrowser HTML.
A:
Yous should use HttpWebRequest and HttpWebResponse objects. Simple sample (found in web, tested, working):
HttpWebRequest myWebRequest = (HttpWebRequest)HttpWebRequest.Create(@"http://www.[pagename].com");
myWebRequest.Method = "GET";
HttpWebResponse myWebResponse = (HttpWebResponse)myWebRequest.GetResponse();
StreamReader myWebSource = new StreamReader(myWebResponse.GetResponseStream());
string myPageSource = string.Empty;
myPageSource = myWebSource.ReadToEnd();
myWebResponse.Close();
zgorawski
2010-10-12 13:29:49
I don't think that's what I need as I am altering the HTML in the WebBrowser control (adding new divs, form controls). I need to save the HTML directly from the control, not from a URL.
dgwyer
2010-10-12 14:11:11