我的代码
var info = new ProcessStartInfo(path);
info.WorkingDirectory = path;
info.WindowStyle = ProcessWindowStyle.Maximized;
var p = Process.Start(info);
它将打开一个文件(.pdf,但以后可能是另一种类型的文件)在某些情况下,没有安装用于打开它的程序,所以它向我显示 windows 消息
Windows 无法打开此文件
并让我搜索一些程序来打开它。
我怎样才能避免这种情况?我想显示另一条消息。在try/catch
它不会抛出任何类型的异常,所以它不工作。
我试过了,if is only .pdf 来检测是否安装了任何程序
var key = Registry.ClassesRoot.OpenSubKey(".pdf");
if(key != null)
// Not installed!
但它不起作用。我得到了一个密钥,但我已经卸载了 Foxit 阅读器(而且我使用 CCleaner 删除了冲突密钥,但仍然有 .pdf 密钥)
请帮忙