2

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

Horsat
  • 21
  • 1

1 Answers1

1

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.

Hicham O-Sfh
  • 731
  • 10
  • 12
  • 2
    In .Net Framework (since `UseShellExecute = true` by default). In .Net Core / .Net 5+, it defaults to `UseShellExecute = false`. So you have to set it to `true` beforehand. – Jimi May 07 '21 at 09:26