简体   繁体   English

WPF Process.Start(pdf) 不打开 PDF

[英]WPF Process.Start(pdf) Doesn't open the PDF

I have a WPF Application, in which I am triggering a PDF file to open on a button click using我有一个 WPF 应用程序,其中我正在触发一个 PDF 文件以使用单击按钮打开

System.Diagnotics.Process.Start(PDFfile.pdf);

The PDFfile.pdf and MyApplication.exe exist in the same folder. PDFfile.pdf 和 MyApplication.exe 存在于同一文件夹中。

The issue is, PDF file doesn't open.问题是,PDF 文件没有打开。 When I checked in Task Manager, the Acrobat Reader XI process appears running.当我在任务管理器中签入时,Acrobat Reader XI 进程似乎正在运行。 The weird part is, while this particular process is running, any other PDF file on PC also does not open on double-click.奇怪的是,当这个特定进程正在运行时,PC 上的任何其他 PDF 文件也不会在双击时打开。 I have checked my PDF file association is with Acrobat Reader XI on my system.我检查了我的 PDF 文件关联是否与我系统上的 Acrobat Reader XI 关联。 OS: Windows 10, 64-bit C# 7.0操作系统:Windows 10、64 位 C# 7.0

Can someone help me figure out the issue or give some pointers, please?有人可以帮我解决问题或提供一些指示吗?

I have read this question but wasn't much help.我已经阅读了这个问题,但没有太大帮助。

It should work when applied as follows.它应该在如下应用时起作用。

Properties -> right click Open to Resources.resx -> Top Left Add Existing File -> select the file.属性 -> 右键单击 Open to Resources.resx -> 左上角添加现有文件 -> select 文件。

byte[] resourceFile = Properties.Resources.PDFfile;
        string destination = Path.Combine(Path.GetTempPath(), "PDFfile.pdf");
        System.IO.File.WriteAllBytes(destination, resourceFile);
        Process.Start(destination);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM