Launching browser from windows application
June 14th, 2007 by Chris
This is a very simple tip that I figured I should post. Its a common thing to want to launch a web browser from your application when a user clicks on a link, or presses a button. The simplest way to perform this is to use the following line of code, that's right, its one single line of code to do it.
C#:
System.Diagnostics.Process.Start("http://www.microsoft.com")
Now the benefits of using the above line of code, it will use the users default browser, so if the user has their default browser set to Firefox, then Firefox is launched, if Internet Explorer is the default, then it is used. The key to making sure this works however is to always include the protocol portion of the URL.
Posted in Windows Forms |