Elie
Elie

Reputation: 13853

Include and Reference Resource File from C# class

I have an image that is used in some PDF files that my C# application generates. I know how to reference the image file when it is located in my workspace, but when I compile the program, I don't see the image anywhere in the compiled directory.

Can someone tell me what happened to that file, or do I have to manually package the file along with my program when I send the program to the users? I added the image to the workspace by drag-drop to the resource directory of one of my namespaces.

Upvotes: 0

Views: 1254

Answers (2)

Jon Skeet
Jon Skeet

Reputation: 1500893

Hmm... I'm not sure about the whole drag-drop business, but if it's all working the resource will have been embedded into your assembly.

I suggest you have a look with Reflector - you can see the resources embedded within assemblies using that.

Have a look at the build properties for the item in Solution Explorer - in particular, if the build action is Embedded Resource then it will indeed be built into the assembly.

Upvotes: 1

Michael Petrotta
Michael Petrotta

Reputation: 60902

Check the file's properties in Visual Studio. Have you set the CopyToOutputDirectory property to something besides Do not copy?

Upvotes: 2

Related Questions