How to get path of Properties.Resources.Image in .NET

Crystal picture Crystal · Jan 10, 2013 · Viewed 19.4k times · Source

I included an image as a resource following this post: How to create and use resources in .NET

I am using PDFSharp library to create a PDF. The method to draw an image, requires the path of the image. How do I get the path of Properties.Resources.Image?

Or is there another way to do this?

Answer

Tilak picture Tilak · Jan 10, 2013

The Properties.Resources.Image is in-memory resource.

You can save Image to temp file and the get the path.

var path = Path.GetTempPath();
Properties.Resources.logo.Save(path);

Above uses Bitmap.Save