gpt4 book ai didi

c# - 打开包含查询字符串的 URL

转载 作者:行者123 更新时间:2023-11-30 19:18:00 25 4
gpt4 key购买 nike

我需要能够从 C# 应用程序在浏览器中打开链接。通常,我会使用这样的代码打开链接:

Process.Start(new ProcessStartInfo("explorer.exe", @"http://www.google.com"));

不幸的是,只有当 URL 包含如下查询字符串时,它才能成功打开资源管理器而不是浏览器: http://www.google.com/search?q=stackoverflow

如何打开带有查询字符串的 URL?

编辑说明:我使用的是 Windows 8 和非 IE 默认浏览器。我在尝试仅使用 Process.Start 时看到与“类未注册”相同的错误,如下所述:Process.Start(url) broken on Windows 8/Chrome - are there alternatives?

最佳答案

终于找到了一个解决方案——令人印象深刻的是,在几年前编写批处理文件后,我没有开始尝试这个,这很常见。

Process.Start(new ProcessStartInfo("explorer.exe", "\"" + @"http://www.google.com/search?q=stackoverflow" + "\""));

只需在其周围添加引号似乎就可以正常工作。

关于c# - 打开包含查询字符串的 URL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14585709/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com