Last active
June 18, 2018 09:41
-
-
Save yehorhromadskyi/6e56f0b1da49aaee96c1fef8b425a3a9 to your computer and use it in GitHub Desktop.
Read image resource as byte array
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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