1

Possible Duplicate:
How to open in default browser in C#

How to open "file://D:/help.html#selclass" with default browser in C#, is there any example?

Thanks Dma

Community
  • 1
  • 1
Da Ma
  • 391
  • 4
  • 17
  • i don't think so. my main target is "#selclass"; and it's true that "Process.Start("file://D:/help.html#selclass"); " can open "help.html", but "#selclass" doesn't work. "#selclass" is removed by IE (test in ie7). – Da Ma Mar 28 '11 at 08:32
  • More detail: process.start("iexplore", "D:/help.html#selclass"); but IE may not the default browser. and when I get default browser from register. firefox doesn't work with #selclass, firefox replace # by %23. can any one help me? – Da Ma Mar 28 '11 at 08:38

4 Answers4

0
Process.Start("file://D:/help.html#selclass");
Cody Gray - on strike
  • 239,200
  • 50
  • 490
  • 574
Sasha Reminnyi
  • 3,442
  • 2
  • 23
  • 27
  • i don't think so. my main target is "#selclass"; and it's true that "Process.Start("file://D:/help.html#selclass"); " can open "help.html", but "#selclass" doesn't work. "#selclass" is removed by IE (test in ie7). – Da Ma Mar 28 '11 at 08:34
  • Could you pass it as a parameter? for example file://D:/help.html?cl=selclass – Sasha Reminnyi Mar 28 '11 at 09:22
  • The IE only open "help.html" and remove "?cl=selclass"; you can have a try. – Da Ma Mar 28 '11 at 09:50
0
var p = Process.Start(@"D:\help.html");
while (!p.HasExited) Thread.Sleep(10);

// carry on
carlsb3rg
  • 752
  • 6
  • 14
0

You could:

  1. Create a temporary .URL file (see here for instance) that features #selclass in the URL.
  2. Open the .URL using Process.Start(...).
  3. Delete the temporary .URL file.
DuckMaestro
  • 15,232
  • 11
  • 67
  • 85
  • Thanks so much! does it work in firefox? it's an unoffice solution, how about win7/winxp or IE7/IE8? – Da Ma Mar 28 '11 at 09:52
  • .URLs work with whatever the default browser is. And the file format spans Windows 7 back to Windows 9x I believe. – DuckMaestro Mar 28 '11 at 16:28
0

I got default browser firstly through register table; and then call

Process.Start(browser, url);

It works

Da Ma
  • 391
  • 4
  • 17