本文介绍了我如何以编程方式检查文件尝试的Process.Start(),它之前的文件存在关联?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的。NET Windows窗体应用程序生成一个PDF格式的报告,这是我要展现给用户。

My .Net Windows Forms application generates a PDF report, which I want to show to the user.

而不是仅仅假设客户端PC中安装了PDF阅读器和盲目扔的PDF在操作系统打开,有没有办法来核对文件关联的列表中的客户端先,然后显示一个的你需要安装一个PDF浏览器的应用程序 - 这里有几个建议.. 的?对话框,如果PDF是不是注册类型

Instead of just assuming the client PC has a PDF viewer installed and blindly throwing the PDF at the Operating System to open, is there a way to check against the list of file associations on the client beforehand, then show a "you need a PDF viewer application installed - here's a couple of suggestions.." dialog if PDF isn't a registered type?

我发现了很多的问题和有关更改或登记文件关联的答案,但我只想要一个简单的方法来查询列表,而不是改变它。

I've found a lot of questions and answers about changing or registering file associations, but I just want an easy way to query the list, not change it.

我想一个解决方案,在Windows XP操作系统(操作系统,Vista中,Win7的)的作品。

I'd like a solution that works on Windows XP onwards (WinXP, Vista, Win7).

感谢您的帮助

推荐答案

最好不要使用注册表直接,但依赖于Windows的API来代替。这里是SO一个链接,让.NET解决方案:How我会收到文件类型信息的基础上延伸? (未MIME)在C#

It's better not use the registry directly but rely on the Windows API instead. Here is a link on SO that gives a .NET solution: How do I get File Type Information based on extention? (not MIME) in c#

这篇关于我如何以编程方式检查文件尝试的Process.Start(),它之前的文件存在关联?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-28 15:35