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
Tilak
  • 30,108
  • 19
  • 83
  • 131
  • 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: http://stackoverflow.com/questions/2707799/start-default-browser-windows – Simon Whitehead Dec 13 '12 at 04:29

2 Answers2

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");
Michael Liu
  • 52,147
  • 13
  • 117
  • 150
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.

Murtuza Kabul
  • 6,438
  • 6
  • 27
  • 34