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.
enter image description here

could tell what's wrong there?
enter image description here

you need set file testimg.png "embedded resource." resource name resources/testimg.png.


Comments

Popular posts from this blog

Delphi XE2 Indy10 udp client-server interchange using SendBuffer-ReceiveBuffer -

Qt ActiveX WMI QAxBase::dynamicCallHelper: ItemIndex(int): No such property in -

Enable autocomplete or intellisense in Atom editor for PHP -