简体   繁体   中英

How to get image path from Resource files

I am storing images in Resource files but the PDF Lib I am using needs image path as string in order to embed images in the output.

But honestly, I couldn't find any way to do that.

将图像提取到磁盘上的临时位置,然后将该临时位置提供给PDF库。

You can use Assembly.GetManifestResourceStream(resource_name_of_the_image) to access the image's stream, write it to TEMP directory and use this path.

For example, if you have an image file in your project at the path " Resources\\Images\\Image.png " and the project's assembly default namespace is " RootNamespace ", you can access the image's stream from within this assembly's code with

Assembly.GetExecutingAssembly().GetManifestResourceStream("RootNamespace.Resources.Images.Image.png")

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM