Process.Start(“IExplore.exe”);
Does this always work, on every machine ? If not, how to do it properly ?
… EDIT: ……………………………
The problem with Process.Start(“http://www.example.com/“); is that we have to target a local html file, with some querystring specifying which page to load in the html frameset.
So our URL looks like the following:
G:\PathToHelpFolder\index.html#search?page=1.html
If you pass this path to Process.Start, an error is generated: “cannot find the file”. This is caused by the querystring at the end. (#search?page=1.html)
So, we have to start explorer (or default browser would be better) with the filepath as a command line argument. We found the method above at the MSDN documentation. (Process.Start(“IExplore.exe”);) Our only question is if this method is reliable enough to deploy to a commercial app. Mono isn’t a problem, only windows systems are targeted.
… EDIT : Our solution ……
Our solution was to get the default browser from the registry, and start that with the filename as argument. (as stated in: Launching default browser with html from file, then jump to specific anchor)
This should work on every machine that has an executable called
IExplore.exein a location thatProcess.Startcan find by using the PATH environment variable.Process.StartdocumentationIf someone has renamed or removed
IExplore.exe, or it’s in a location that’s not in the PATH environment variable then it won’t work.However, if your goal is to open a browser then I’d go with passing the URL as others have suggested.