Wednesday, 14 March 2012

Reading embedded resources in .Net

I always forget the first important step; i.e. remember to mark the Build Action property of a resource to "Embedded resource"

Then use:

Assembly myAssembly = GettingExecutingAssembly();
Stream myStream = myAssembly.GetManifestResourceStream(name-and-path-string-to-embedded-resource);


Where name-and-path-string-to-embedded-resource is the full namespace string of the resource e.g. "myproject.images.image.png"

No comments:

Post a Comment