4

我有一个带有“帮助”上下文菜单的 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??
}
4

3 回答 3

6
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
于 2013-03-26T16:26:51.600 回答
1

添加using System.Diagnostics;到您的使用中,然后调用:

Process.Start("path to pdf")

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

于 2013-03-26T16:24:11.930 回答
1

试试这个(您只需要 PDF 文件的路径,无需将其添加到资源中):

using System.Diagnostics;

Process.Start(“Path_of_PDFFile”)
于 2013-03-26T16:22:16.013 回答