如何打开一个PDF文件,这也是一个项目资源? [英] How to open a PDF file that is also a project resource?

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

问题描述

我有,我已经在进口作为资源到我的项目的PDF文件。该文件是一个帮助文件,所以我希望能够与每个部署包括它。我希望能够打开这个文件,在点击按钮。

I have a PDF file that I have imported in as a resource into my project. The file is a help document so I want to be able to include it with every deployment. I want to be able to open this file at the click of a button.

我已经设置生成操作为使嵌入的资源。所以,现在我希望能够打开它。然而,当我尝试访问资源 - My.Resources.HelpFile - 这是一个字节数组。我怎么会去打开这个,如果我的知道的是,最终用户有适合打开PDF文档的程序?

I have set the build action to "Embedd Resource". So now I want to be able to open it. However, When I try accessing the resource - My.Resources.HelpFile - it is a byte array. How would I go about opening this if I know that the end-user has a program suitable to opening PDF documents?

如果我错过了previous问题,请点我到正确的方向。我发现关于在的一个应用程序中打开PDF文件的若干问题的,但如果没有Adobe Reader中打开分开我不在乎。

If I missed a previous question please point me to the right direction. I have found several questions about opening a PDF within an application, but I don't care if Adobe Reader opens seperately.

推荐答案

创建新进程:

string path = Path.Combine(Directory.GetCurrentDirectory(), "PDF-FILE.pdf");
Process P = new Process {
    StartInfo = {FileName = "AcroRd32.exe", Arguments = path}
};
P.Start();

为了这个工作,在Visual Studio设置复制到输出目录已被设置为复制始终为PDF文件。

In order for this to work, the Visual Studio setting Copy to Output Directory has to be set to Copy Always for the PDF file.

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

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