Skip to content

Instantly share code, notes, and snippets.

@yehorhromadskyi
Last active June 18, 2018 09:41
Show Gist options
  • Save yehorhromadskyi/6e56f0b1da49aaee96c1fef8b425a3a9 to your computer and use it in GitHub Desktop.
Save yehorhromadskyi/6e56f0b1da49aaee96c1fef8b425a3a9 to your computer and use it in GitHub Desktop.
Read image resource as byte array
byte[] OpenImage()
{
byte[] imageData = null;
var assembly = GetType().GetTypeInfo().Assembly;
string filePath = "AssemblyName" + ".FolderName.FileName.extension";
using (Stream s = assembly.GetManifestResourceStream(filePath))
{
long length = s.Length;
imageData = new byte[length];
s.Read(imageData, 0, (int)length);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment