How to get resource as byte array in c#? -
i added image c# project project settings -> resources
how can image @ runtime?
trying this:
public byte[] getresource(string resourcename) { system.reflection.assembly asm = assembly.getentryassembly(); // list resources in assembly - test string[] names = asm.getmanifestresourcenames(); //even here testimg.png not presented system.io.stream stream = asm.getmanifestresourcestream(resourcename); //this return null of course byte[] data = new byte[stream.length]; stream.read(data, 0, (int)stream.length); return data; }
i call function way:
byte[] data = getresource("testimg.png");
but see image in resources folder in project explorer.
could tell what's wrong there?
you need set file testimg.png
"embedded resource." resource name resources/testimg.png
.
Comments
Post a Comment