C#如何在我的项目资源中打开PDF?

我有一个带有“帮助”上下文菜单的winfrom GUI。 点击后,我想打开该应用程序的用户手册。 手册是pdf,存储在应用程序资源中。

问题:如何为用户打开此内容?

我正在使用的代码

System.Diagnostics.Process process = new System.Diagnostics.Process(); bool adobeInstall = false; RegistryKey adobe = Registry.LocalMachine.OpenSubKey("Software").OpenSubKey("Adobe"); if (adobe != null) { RegistryKey acroRead = adobe.OpenSubKey("Acrobat Reader"); if (acroRead != null) adobeInstall = true; } if (adobeInstall == true) { ///Open the pdf file?? } 

 string locationToSavePdf = Path.Combine(Path.GetTempPath(), "file name for your pdf file.pdf"); // select other location if you want File.WriteAllBytes(locationToSavePdf,Properties.Resources.nameOfFile); // write the file from the resources to the location you want Process.Start(locationToSavePdf); // run the file 

试试这个(你需要一个PDF文件的路径,不需要将它添加到资源):

 using System.Diagnostics; Process.Start(“Path_of_PDFFile”) 

using System.Diagnostics;添加using System.Diagnostics; 给你使用,然后打电话:

Process.Start("path to pdf")

您不需要找到PDF Reader exe或任何东西。 只需调用所需文件的路径即可。