How can I get a list of all embedded resources defined in my application?

余生长醉 提交于 2020-01-25 06:55:26

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!