以编程方式将资源加载为字节数组 [英] load resource as byte array programmatically
本文介绍了以编程方式将资源加载为字节数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我添加了图像作为文件,并将类型设置为资源(请参见屏幕截图)
如何在不使用resx文件等的情况下将其作为字节数组拉出?
I added image as file and set type as resource (see screenshot) How do I pull it out as byte array without using resx files, etc?
推荐答案
该过程在如何使用Visual C#嵌入和访问资源中进行了描述。
本质上,它需要使用反射,使用 组装
类。
Essentially it requires use of reflection, using the Assembly
class.
Stream imageStream =
currentAssembly.GetManifestResourceStream("Resources.logo_foot.png");
请参见如何在C#中将流转换为byte []?,详细了解如何获取 byte [ ]
来自流
。
See How to convert an Stream into a byte[] in C#? for details of how to get a byte[]
from a Stream
.
这篇关于以编程方式将资源加载为字节数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文