Embedded binary resources - how can I list attached image files?

I followed the instructions in this book , in the "Resources" chapter, etc., and I cannot figure out how to do this; replace this:

images.Add(new BitmapImage(new Uri(@"/Images/Deer.jpg", UriKind.Relative))); images.Add(new BitmapImage(new Uri(@"/Images/Dogs.jpg", UriKind.Relative))); images.Add(new BitmapImage(new Uri(@"/Images/Welcome.jpg", UriKind.Relative))); 

using a loop that just runs all the embedded image resources to avoid hard-coding image names and paths. How can I find out the names of the embedded files?

I selected the images I wanted to embed and indicated:

Create action = resource and copy to output directory = do not copy

in the Properties window. The build has grown significantly, and I'm sure the images are really embedded.

+4
source share
1 answer

try using something with GetManifestResourceNames or take a look at the ResourceManager object.

 Assembly assembly = Assembly.GetExecutingAssembly(); foreach (string s in assembly.GetManifestResourceNames()) { //match on filenames here. you can also extention matching to find images. } 
+5
source

All Articles