I can't figure out how to display a local webpage. I've tried messing with the webBrowser control but it keeps adding "http://" to the front of the local webpage address, and if I try to change it from within the code like this:

webBrowser1.Url = "file:\\webpage\Maphs v1.htm";

I get the following error:
error CS1009: Unrecognized escape sequence

Can anyone help me out? The page I want to display is just one page, and it is stored locally in the same folder as the program.

Thanks in advance for any help!

Try putting your slashes round the correct way, eg


Thanks for your response. I was experimenting with them the otherway round.

If I had them the correct way, I'd get this error:

error CS0029: Cannot implicitly convert type 'string' to 'System.Uri'

Any ideas?

The Uri type is not string so you have to implement the code as follow

webBrowser1.Url = new Uri( "file:\\webpage\Maphs v1.htm");

I just tried that. It compiled successfully but I got the following error at runtime:

Windows cannot access \\webpage\Maphs v1.htm
The network path was not found.

The file DOES exist at that location, which is all the more confusing...

Perhaps you could try webBrowser1.Navigate(urlstring) instead of webBrowser1.Url.

The file wont be at \\webpage\blah.htm, its at c:\webpage\blah.html
the \\something notation usually means machine name, is your PC really called "webpage"?

ddanbe: I tried "webBrowser1.Navigate(webpage/Maphs v1.htm)", that gave me a 404.

The HTML file is in a directory called "webpage", which is in the same directory as the program.

I wanted a local reference to the file, so that if I wanted to move the program's directory, it would work anyway. Evidently, that didn't happen.
Is there a way to make a local reference like that? Or should I just give up and hardcode the path in (which works)?

You got me thinking about the location, and with some googling, I solved it.

I used "Application.ExecutablePath" to give me the location of the executable as a string, then added "webpage/maphs v1.htm" to it and used that - the webpage now displays.

Thanks for the help.