How to open html file with anchor(#) in C# with default browser

徘徊边缘 提交于 2019-12-06 09:14:56

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");

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.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!