Rohit
Rohit

Reputation: 6613

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 will be moved to BIN on compilation and from there installer can access that file.

IDEAS ...

Upvotes: 0

Views: 1951

Answers (2)

Rohit
Rohit

Reputation: 6613

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.

Upvotes: 1

Alex Shtoff
Alex Shtoff

Reputation: 2640

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!

Upvotes: 3

Related Questions