Process.Start(link)省略了部分链接 [英] Process.Start(link) omits part of the link

查看:194
本文介绍了Process.Start(link)省略了部分链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


可能重复:

打开带有查询字符串的html文件

我'使用c#编写一个简单的控制台应用程序,我正在尝试使用name参数打开一个本地html文件。现在我正在使用const url(用于测试...):
file:/// D:/index.html?name = bob

I'm writing a simple console app using c# and I'm trying to open a local html file with "name" parameter. For now I'm using const url (For testing...): "file:///D:/index.html?name=bob"

代码很简单:

class Program
    {
        static void Main(string[] args)
        {
            string link = @"file:///D:/index.html?name=bob";
            Process.Start(link);
        }
    }

但它会打开浏览器并显示以下链接:file :/// d:/index.htm明明。
有谁知道为什么它会省略'name'参数以及如何修复它?

But it opens the browser with the link: "file:///D:/index.html". Do anyone knows why does it omit the 'name' parameter and how to fix it?

谢谢!

推荐答案

如果您不介意绑定到特定浏览器(而不是系统中定义的浏览器),则可以正常工作:

If you don't mind binding to a specific browser (rather than the one defined in the system), this works:

Process.Start("iexplore.exe", @"file:///D:/index.html?name=bob")

否则我猜你可以推断出相关的程序(可能是通过注册表)并使用相同的技术。

Otherwise I'm guessing you could deduce the associated program (probably via the registry) and employ the same technique.

这篇关于Process.Start(link)省略了部分链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆