Skip to content

Instantly share code, notes, and snippets.

@dhcgn
Last active May 2, 2016 14:27
Show Gist options
  • Save dhcgn/2bf72a270ed19447d67e7026a912a9bb to your computer and use it in GitHub Desktop.
Save dhcgn/2bf72a270ed19447d67e7026a912a9bb to your computer and use it in GitHub Desktop.
public static byte[] ExtractResource(string filename)
{
var assembly = Assembly.GetExecutingAssembly();
var name = assembly.GetManifestResourceNames().Single(s => s.EndsWith(filename));
var stream = assembly.GetManifestResourceStream(name);
var ms = new MemoryStream();
stream.CopyTo(ms);
return ms.ToArray();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment