It is often a requirement to open the default web browser and browse to a specific Url from a Windows Forms, WPF or even Console application. The easiest method I’ve discovered is to make use of the System.Diagnostics.Process class:
using System;
using System.Collections.Generic;
using System.Text;
using System.Diagnostics;
namespace OpenDefaultBrowser
{
class Program
{
static void Main(string [] args)
{
Process .Start("http://softwarebydefault.com" );
}
}
}
In most scenarios the code snippet listed above works without a problem. The only issue I foresee being in an environment where the user account used to execute your application not having sufficient permissions to execute the default browser application.
For more information see MSDN Process Class
0 Responses to “Open a Website from C#”