'The system cannot find the file specified' when clicking link

I am following this answer about making hyperlink work in a RichTextBox? by adding this:

private void mRichTextBox_LinkClicked (object sender, LinkClickedEventArgs e) {
    System.Diagnostics.Process.Start(e.LinkText);
}

(Actually what I’m really doing is to go to the property of the control, click on the LinkClicked action, and just put the Start() method in there.)

However when clicking the link I get this error:
System.ComponentModel.Win32Exception: 'An error occurred trying to start process 'https://example.com' with working directory 'XYZ'. The system cannot find the file specified.'

Why is that?

>Solution :

If you are using .NET 6 or higher, try this:

 Process.Start( new ProcessStartInfo { FileName = e.LinkText ,  UseShellExecute = true } );

Leave a Reply