如何获取我的应用程序中定义的所有嵌入式资源的列表? [英] How can I get a list of all embedded resources defined in my application?

查看:32
本文介绍了如何获取我的应用程序中定义的所有嵌入式资源的列表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何以编程方式获取作为资源或内容嵌入的所有文件(例如图像)的列表?

How to get a list of all files (e.g. images) embedded as resources or content programmatically?

我试过了

ResourceDictionary res = Application.Current.Resources;

但这不会返回任何文件.

But this does not return any files.

推荐答案

如果资源具有构建操作 Content 则无法枚举它们.您只能通过名称直接访问它们(因此您必须知道名称).

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).

对于具有构建操作Resource嵌入式资源的资源,您可以使用 Ivan 的解决方案.

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.

这篇关于如何获取我的应用程序中定义的所有嵌入式资源的列表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆