How to load local HTML pages in a WebBrowser control in C #

I have a number of local HTML pages. I want to display these local HTML pages in a web browser. When I add a new page, it should be added to the previous page.

Here is sample code for configuring url

for( int i=0; i<=filecount; i++)
    web-browser.Url = new Uri(filepath[i]);

But at runtime its showing the popup file and web browser is empty.

+5
source share
2 answers

You can load one page as

FileStream source = new FileStream(filepath, FileMode.Open, FileAccess.Read);
webBrowser1.DocumentStream = source;

or even how

string html = File.ReadAllText(filepath);
webBrowser1.DocumentText = html;

But if you have images, css or js in relative paths, use

Uri uri = new Uri(filepath);
webBrowser1.Navigate(uri);
+19
source
webrowser.Navigate(filepath[i]); 

something like this i remember ...;)

0
source

All Articles