Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>It had been bugging me that it wasn't possible to do this so I've done a bit of digging and have come up with a way of getting a list of all image files with the build action of "Resource". - Yes, this isn't quite what was asked for but hopefully this will still be useful.</p> <p>If you really must use a build action of "Content" I'd use a T4 script to generate the list of files at build time. (This is what I do with one of my projects and it works fine.)</p> <p>Assuming that the images are in a folder called "images" you can get them with the following:</p> <pre><code>var listOfImageResources = new StringBuilder(); var asm = Assembly.GetExecutingAssembly(); var mrn = asm.GetManifestResourceNames(); foreach (var resource in mrn) { var rm = new ResourceManager(resource.Replace(".resources", ""), asm); try { var NOT_USED = rm.GetStream("app.xaml"); // without getting a stream, next statement doesn't work - bug? var rs = rm.GetResourceSet(Thread.CurrentThread.CurrentUICulture, false, true); var enumerator = rs.GetEnumerator(); while (enumerator.MoveNext()) { if (enumerator.Key.ToString().StartsWith("images/")) { listOfImageResources.AppendLine(enumerator.Key.ToString()); } } } catch (MissingManifestResourceException) { // Ignore any other embedded resources (they won't contain app.xaml) } } MessageBox.Show(listOfImageResources.ToString()); </code></pre> <p>This just displays a list of the names, but hopefully it'll be easy to change this to do whatever you need to.</p> <p>Any suggestions for improving this code will be greatly appreciated.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload