How do I set the url of an htmldocument after I’ve written to it. For example:
WebBrowser wb = new WebBrowser();
wb.Navigate(new Uri(location, UriKind.Absolute));
IHTMLDocument2 myDoc = new HTMLDocumentClass();
myDoc.write(new object[] { wb.DocumentText});
myDoc.close();
If I do myDoc.url = "http://www.google.com" it attempts to load google.
How do I set the url without having it attempt to load that url?
These steps should give you a document with correct URL and your own content:
This code shows how to do it:
Note: It’s hard to guess how much content can be downloaded between steps 1 and 2 because loading happens asynchronously. So it’s probably good to check if the document is indeed empty before doing step 3. If not, clear the document and proceed.