Search code examples
c#.netwpfpdf.net-core

Win32Exception when opening a pdf file


I try to open a PDF file with whatever the user has setup on his computer for PDFs.

I found this on Stackoverflow:

        System.Diagnostics.Process.Start(helpPath);

Or

        ProcessStartInfo startInfo = new ProcessStartInfo(helpPath);
        Process.Start(startInfo);

Both will give me the same message:

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


Solution

  • You can open pdf in default web browser.

    Use:

    Process.Start("explorer", helpPath);
    

    For Internet Explorer:

    Process.Start("C:\Program Files\Internet Explorer\iexplore.exe", helpPath);