从 WPF 应用程序打开具有默认 windows 行为的 pdf

Open a pdf with default windows behaviour from a WPF application

我想使用用户保存的默认 windows 行为(例如 Internet Explorer、Adobe 等)打开 PDF。

我找到了这个解决方案

并在此处实施:

        ProcessStartInfo startInfo = new ProcessStartInfo("MyPdfPath");
        Process.Start(startInfo);

遗憾的是我遇到了一个错误:

   System.ComponentModel.Win32Exception: "The specified executable is not a valid application for this OS platform."

我尝试 google 这个错误,但前十个解决方案都没有奏效。

系统将其视为可执行文件,获取文档行为的一种方法是将 UseShellExecute 设置为 true:

ProcessStartInfo startInfo = new ProcessStartInfo("MyPdfPath");
startInfo.UseShellExecute = true;
Process.Start(startInfo);