Launching default browser with html from file, then jump to specific anchor

Posted by Holman716 on Stack Overflow See other posts from Stack Overflow or by Holman716
Published on 2010-04-15T15:46:06Z Indexed on 2010/04/15 16:03 UTC
Read the original article Hit count: 163

Filed under:

I need to open an html file from the program root directory and have it jump to a specified anchor. I can open the file perfectly fine with a simple

System.Diagnostics.Process.Start("site.html")

but as soon as I try to add the anchor to the end it ceases to be able to find the file.

I was able to put the anchor in there and still have it launch with

string Anchor

Anchor = "file:///" + Environment.CurrentDirectory.ToString().Replace("\", "/") + "/site.html#Anchor"; System.Diagnostics.Process.Start(Anchor);

However as soon as the browser launches it drops the anchor. Any suggestions?

© Stack Overflow or respective owner

Related posts about c#