3

I am trying to open a contextual help file in c#.

When i specify no anchor, it works perfectly.

Process.Start("C:/Help/Help.htm")

But when i specify anchor, it does not open

Process.Start("C:/Help/Help.htm#_Toc342057538")

Internally it changes '#' to '%23' and the path becomes "c:\Help.htm%23_Toc342057538" which browser is unable to recognize.

Browser is successfully opening the path "c:\Help.htm#_Toc342057538"

How to stop this automatic conversion by Process.Start. The same behavior is observed, if i give the anchor label as another argument, or use Uri class.

EDIT Same behavior is observed, when i enter the string in Window Run. Following command also convert # to %23, which browser cannot recognize.

chrome c:/Help.htm#_Toc342057538
1
  • Have you tried opening the users default browser and passing the file as an argument (the second paramter in Process.Start)? An example of the default browser check is here: stackoverflow.com/questions/2707799/… Commented Dec 13, 2012 at 4:29

2 Answers 2

3

On my Windows 7 system, both of the following open C:\Help\Help.htm in Internet Explorer and scroll to the _Toc342057538 anchor:

Process.Start("iexplore", "file://C:/Help/Help.htm#_Toc342057538");
Process.Start("iexplore", @"C:\Help\Help.htm#_Toc342057538");

For Firefox and Chrome, only the file protocol seems to work:

Process.Start("firefox", "file://C:/Help/Help.htm#_Toc342057538");
Process.Start("chrome", "file://C:/Help/Help.htm#_Toc342057538");
Sign up to request clarification or add additional context in comments.

Comments

0

Try this out. I just did it myself and working in internet explorer

string s = "file:///D:/tmp/test.html%23test";
      s = uri.UnescapeDataString(s);

      Process.Start(s);

Please let me know if it is working or not for you.

2 Comments

is your default browser firefox, mine is internet explorer and it seems to work properly in it
it has worked with file://D:... and not with file:///d:.... Seems like extra backslash was problem

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.