PassionateDeveloper
PassionateDeveloper

Reputation: 15138

Open a pdf with default windows behaviour from a WPF application

I want to open a PDF with the default windows behaviour the user has saved (e.g. internet explorer, adobe, whatever).

I found this solution Opening a .pdf file in windows form through a button click

and implemented it here:

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

Sadly I got an Error:

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

I tried to google this error, but nothing of the first ten solution ideas worked.

Upvotes: 0

Views: 403

Answers (1)

user14215102
user14215102

Reputation:

The system is treating it like an executable, one way to get the document behavior is to set UseShellExecute to true:

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

Upvotes: 2

Related Questions