-3

In the button click event handler of a windows form, it looks at a file path c:\dev\Index.htm. I need to open this file in a browser window such as IE or chrome. How can I do this? Any example is very much appreciated.

Thank you!

Jyina
  • 2,530
  • 9
  • 42
  • 80
  • possible duplicate of [How do you open a local html file in a web browser when the path contains an url fragment](http://stackoverflow.com/questions/7197967/how-do-you-open-a-local-html-file-in-a-web-browser-when-the-path-contains-an-url) – Abhinav May 11 '15 at 22:11
  • Possible duplicate of http://stackoverflow.com/questions/10503909/how-can-i-launch-a-url-in-the-users-default-browser-from-my-application – Ulric May 11 '15 at 22:17

1 Answers1

5

I'm not sure if I understood your problem right. If you want to open an extern browser you can use:

  System.Diagnostics.Process.Start("C:\\dev\\Index.htm");

if you want to show it in your Form, you have to use IE through a webBrowser. You can load your file via URI

yourBrowser.Url=new Uri("C:\\dev\\index.htm");

or you could load it through reading the Htm file manual and setting it as Document

yourBrowser.DocumentText=System.IO.File.ReadAllText("C:\\dev\\index.htm");

there are several other methods, I hope that I could help you.

leAthlon
  • 734
  • 1
  • 10
  • 22