How to get all the image resources in a project’s sub folders?

雨燕双飞 提交于 2019-12-24 10:58:46

问题


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

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?

Thanks


回答1:


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.

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



来源:https://stackoverflow.com/questions/5996847/how-to-get-all-the-image-resources-in-a-project-s-sub-folders

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