Henriette van de Haar
Henriette van de Haar

Reputation: 120

add pdf file as resource to wpf project and start it from there

I added a pdf file ("myfile.pdf") with "Add Existing Item ..." to my wpf project. Then I set the properties of it to "Resource" and "Do not Copy" (similar to the properties of other resources that I have, e.g flowdocuments). Then I tried to execute

           System.Diagnostics.Process.Start("myfile.pdf")

and obtained a 'file not found' error.

When I change the file properties to "build: content" and "copy if newer" everything works fine. However, I would prefer not to have this file in my output directory.

I work with VisualStudio Community 2013. Is it maybe possible that VisualStudio cannot include a pdf file because it cannot compile it?

Upvotes: 1

Views: 726

Answers (1)

Andrey Ganin
Andrey Ganin

Reputation: 359

It's impossible. You can try to write the file from resources to %Temp% and open this File. But you can't control when an external program releases this file and deletes it.

Upvotes: 1

Related Questions