I added image to my c# project from Project settings -> Resources
How can i get this image at runtime?
I trying this:
public byte[] GetResource(string ResourceName)
{
System.Reflection.Assembly asm = Assembly.GetEntryAssembly();
// list all resources in assembly - for test
string[] names = asm.GetManifestResourceNames(); //even here my TestImg.png is 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 this function this way:
byte[] data = GetResource("TestImg.png");
But I see my image in Resources folder in project explorer.

Could anyone tell what's wrong there?

stream.Lengthto anint? It already is anint..LongLengthreturns along.Assembly.GetExecutingAssembly()