问题
How to get a list of all files (e.g. images) embedded as resources or content programmatically?
I tried
ResourceDictionary res = Application.Current.Resources;
But this does not return any files.
回答1:
If the resources have build action Content then there is no way to enumerate them. You can only access them directly by name (so you would already have to know the names).
For resources with build action Resource or Embedded Resource you can use Ivan's solution.
The discussion to this similar question might give you a bit more code and information.
回答2:
Hope this help:
var resourceNames = Assembly.GetExecutingAssembly().GetManifestResourceNames();
来源:https://stackoverflow.com/questions/8149867/how-can-i-get-a-list-of-all-embedded-resources-defined-in-my-application