Haim Kashi
Haim Kashi

Reputation: 399

How do i load html file in WebBrowser?

I have on my hard disk an html file i saved the content from a website with Webclient.

private void DownloadHtml()
        {
            using (var client = new WebClient())
            {
                client.DownloadFile(webSite, OriginalHtmlFilePath);
            }
        }

Now after did some changes with the file content changed only some texts no tags or any scripts i want to load back the html file. So i did:

string html = File.ReadAllText(ScrambledHtmlFilePath);
            Uri Uri = new Uri(ScrambledHtmlFilePath);
            //webBrowser1.DocumentText = html;
            webBrowser1.Navigate(Uri);

In both cases using the html or the Uri its loading the html as local file and therefore im getting some scripts errors.

If i open the file from my hard disk with Chrome or IE it's loading the file online like i surfed to the site im not getting any script errors. The problem is that when im using Chrome or IE its taking like 10-15 seconds untill its loading the file.

How can i load the html file in WebBrowser fast and to be online like if i was openning it with IE or Chrome ?

Upvotes: 0

Views: 601

Answers (1)

Andy G
Andy G

Reputation: 19367

You can set the DocumentText property of the WebBrowser control to the edited-HTML content.

Upvotes: 1

Related Questions