Open a URL from Windows Forms

Viewed 99202

I'm trying to provide a link to my company's website from a Windows Form. I want to be well behaved and launch using the user's preferred browser.

What is the best way to open a URL in the user's default browser from a Windows Forms application?

6 Answers

This article will walk you through it.

Short answer:

ProcessStartInfo sInfo = new ProcessStartInfo("http://mysite.com/");  
Process.Start(sInfo);
using System.Diagnostics;

Process.Start("http://www.google.com/");

This approach has worked for me, but I could be missing something important.

For those getting a "Win32Exception: The System cannot find the file specified"

This should do the work:

ProcessStartInfo psInfo = new ProcessStartInfo
{
   FileName = "https://www.google.com",
   UseShellExecute = true
};
Process.Start(psInfo);

UseShellExecute is descriped further here

For me the issue was due to the .NET runtime as descriped here

Related