C# basic linkLabel doesn't open url, exception unhandled

967 Views Asked by At

This is my simple code, yet it throws me an exception for some reason


    private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
            {
                System.Diagnostics.Process.Start("chrome", "https://www.google.com/");
            }

The Exception:

System.ComponentModel.Win32Exception: 'The system cannot find the file specified.'

I don't understand why this is happening

1

There are 1 best solutions below

1
Hicham O'Sfh On

To open a url using the WinForms's linkLabel component do

private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
    System.Diagnostics.Process.Start("http://www.url.com"); // will automaticaly redirect the user to his default web browser 
}

find more in the official documentation.
take a look there : already answered question.
good luck.