C#如何在我的项目资源中打开PDF? [英] C# How to open a PDF in my project resources?

查看:305
本文介绍了C#如何在我的项目资源中打开PDF?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I have a winfrom GUI that has a 'help' context menu. When clicked, I would like to open the user manual for the application. The manual is a pdf which is stored within the application resources.

问题:如何为用户打开此窗口?

Question: How do I open this for the user?

我正在使用的代码

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

这篇关于C#如何在我的项目资源中打开PDF?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆