如何获得一个项目的子文件夹中的所有图像资源? [英] How to get all the image resources in a project’s sub folders?

查看:105
本文介绍了如何获得一个项目的子文件夹中的所有图像资源?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这样一个项目;我想所有的图像中的图像文件夹中。

I have a project like this; I want to get all the images in the "Images" folder.

如果所有的PNG文件存储在磁盘上的文件夹中,这将是容易的。

If all the png files are stored in a folder on the disk, this would be easy.

但它们嵌入在项目,那么我怎么能访问它们?

But they are embedded in the project, then how can I access them?

甚至进一步,我怎么了图像资源的树数据结构?

Or even further, how do I get a tree data structure of the image resources?

感谢

推荐答案

您可以使用包URI访问它们:

You can access them using a package URI:

Image image = new Image();
image.Source = new BitmapImage(new Uri("pack://application:,,,/Images/ImageCategory1/Burn Disc.png"));

如果你想获得的文件夹结构:

If you want to get the folder structure:

恐怕没有文件夹结构以外,在项目结构被添加到每个资源的名称

I am afraid there is no folder structure other than that the structure in the project is added to the name of each resource.

幸运的是有一种方法来枚举所有资源:<一href="http://stackoverflow.com/questions/1765920/searching-and-listing-wpf-resource-dictionaries-in-a-folder">searching和上市WPF资源字典文件夹中的

Fortunately there is a way to enumerate all resources: searching and listing WPF resource dictionaries in a folder

这篇关于如何获得一个项目的子文件夹中的所有图像资源?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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