使用System.Diagnostics.Process.Start链接到带有#符号的文件 [英] Link to file with # symbol in using System.Diagnostics.Process.Start

查看:64
本文介绍了使用System.Diagnostics.Process.Start链接到带有#符号的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hiya,

我目前正在使用以下格式的链接来实现本地帮助系统:

Hiya,

I am currently working on an implementation of a local help system with links which are in the following format:

System.Diagnostics.Process.Start("file:///D:/Folder/Default.htm#Product.htm")



但是,当用户单击加载该按钮的按钮时,它最多只能加载#号,而不会显示其余部分.浏览器中显示的路径是file:///D:/Folder/Default.htm.我试过使用#号标记的Internet链接,它们很好,它只是指向不起作用的本地文件的链接.任何人都可以提供可供使用的替代库,以便我以这种方式使用吗?



However when the user clicks the button which loads this, it only loads up to the # symbol and doesn''t show the rest. The path shown in the browser is file:///D:/Folder/Default.htm. I''ve tried internet links with the # symbol in and they''re fine, it''s just links to local files which don''t work. Can anyone offer an alternative library to use so I can use it in this way?

推荐答案

我可以确认.至少这是它与最新版本的Mozilla SeaMonkey浏览器在Windows 7中从Shell发出的启动一起工作的方式.看来锚点已被忽略.

有趣的是,如果我直接使用Web浏览器应用程序文件,它将正常工作.例如,这应该起作用:
I can confirm it. At least this is how it works with start issued from the Shell with Mozilla SeaMonkey browser of the most recent version, with Windows 7. It looks like the anchor is ignored.

Interestingly, if I use the Web browser application file directly, it works correctly. For example, this should work:
string browser = //...; path name of the browser application
string commandLine = "file:///D:/Folder/Default.htm#Product.htm";
System.Diagnostics.Process.Start(browser, commandLine);



我确实知道该解决方案不是很好,因为它不是通用的,但是如果我们在Shell中存在这样的缺陷,您可以怎么做(因为此示例表明浏览器可以正常工作,所以这种缺陷是Shell API,而不是浏览器)?

您可以使用相同的代码对其进行改进,只需要从系统注册表检索的数据中计算出browser完整路径名即可.



使用注册表项:



I do understand that this solution is not very good, because it is not universal, but what you can do if we have such a defect in the Shell (because this example shows that the browser works correctly, so this a kind of defect in the Shell API, not the browser)?

You can improve it using the same code, only you would need to calculate the browser full path name out of the data retrieved from system Registry.



Use the Registry key:

HKEY_CLASSES_ROOT\http\shell\open\command



请参阅:
http://msdn.microsoft.com/en-us/library/microsoft.win32. Registry.aspx [ ^ ].

另请参见此CodeProject文章:
使用C#从注册表中读取,写入和删除 [ ^ ].

—SA



Please see:
http://msdn.microsoft.com/en-us/library/microsoft.win32.registry.aspx[^].

See also this CodeProject article:
Read, write and delete from registry with C#[^].

—SA


这篇关于使用System.Diagnostics.Process.Start链接到带有#符号的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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