I know there is built-in Internet explorer, but what I'm looking for is to open Firefox/Mozilla window (run the application) with specified URL. Anyone can tell me how to do that in C# (.nET) ?
-
Do you mean you want to open "user's default" browser or something else? – Ilya Ryzhenkov Oct 21 '08 at 20:02
-
Yes and no. -> the application i code is for my use only, however it'd be nice to know how to open different one. – Skuta Oct 21 '08 at 20:22
6 Answers
You can do this:
System.Diagnostics.Process.Start("firefox.exe", "http://www.google.com");

- 261
- 1
- 5
- 14
This will launch the system defined default browser:
string url = "http://stackoverflow.com/";
System.Diagnostics.Process.Start(url);
Remember that Process.Start(url) might throw exceptions if the browser is not configured correctly.
-
Note that this might fail if there is something wrong with the browser configuration. Make sure you catch the appropriate exceptions. I've just had this reported to me using automated crash reports, no good way to solve it except catching the correct exceptions. – Vegard Larsen Mar 03 '09 at 18:20
-
Sure mime types have to be managed. Hallgrim's snippet works for me. It even makes a new tab in my open Firefox session. Love it. It can also do e.g. file://k:\\test.pdf – Goodies Aug 09 '18 at 19:34
Use the Process class (System.Diagnostics) using the URL as the process name. This will use the system default browser to open the URL. If you specify a browser, you run the risk that the browser doesn't exist.

- 49,173
- 15
- 109
- 139
In Visual Studio click the File -> Browse With... on the menus and then select the browser that you want to use. You can also change the browser there. If the Browse With... menu option doesn't appear then you need to select a project from your solution that that can be launched in a browser.

- 65,082
- 97
- 254
- 325
If you explicitly do not want to use the User's default browser, you can run the browser with the URL as the first argument.
C:\Program Files\Mozilla Firefox>firefox.exe http://google.com
launches Firefox with google for me. But as people have said, you run the risk of it not being installed, or being installed to a different place, etc.

- 99,986
- 30
- 138
- 174
-
wrt installation location, you can check the registry under HKLM\SOFTWARE\Mozilla – Blorgbeard Apr 16 '09 at 12:03