Search code examples
c#.netembedded-resource

load resource as byte array programmatically


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?

enter image description here


Solution

  • The process is described in How to embed and access resources by using Visual C#.

    Essentially it requires use of reflection, using the Assembly class.

    Stream imageStream = 
                currentAssembly.GetManifestResourceStream("Resources.logo_foot.png");
    

    See How to convert an Stream into a byte[] in C#? for details of how to get a byte[] from a Stream.