开发者

Embedding a PDF as a resource in WPF application

I want to embed a PDF file (which is basically have Product details, Release notes) and wants to open that file from menu bar. What would be the best approach. I need to use this file in installer also. So i'm looking for an approach in which file w开发者_开发知识库ill be moved to BIN on compilation and from there installer can access that file.

IDEAS ...


Add the file to the project the builds the EXE (use Add existing file in visual studio). Then right click on the file in visual studio, go to properties, and verify that the build action is "Content" and the copy to output directory is "Always" or "If newer" (whichever suits you).

Then this file will always be copied to the same directory where the EXE resides and your application will be able to access it because it's always in the application's directory.

If the installer just takes the BIN directory then it will also be able to access it because the file will reside in the BIN directory.

Have fun!


Finally i did it in following way: a. We've a folder which contains notes.pdf (used by installshield). b. Created a pre build command to copy the pdf file from installshield folder to output directory. c. use process.start("notes.pdf"); to open the file. As it would look in bin directory first for pdf file and we've already copied it there.

It worked for both Installer version and running application from code.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜