简体   繁体   English

C# 基本链接标签未打开 url,未处理异常

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

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我不明白为什么会这样

To open a url using the WinForms's linkLabel component do要使用 WinForms 的 linkLabel 组件打开 url,请执行以下操作

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.祝你好运。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM