我在我的Resources文件夹中添加了许多图像,以便在我的项目中使用它们。我想通过引用它们的名字在图片框中动态调用它们。我的问题是:
谢谢。
答案 0 :(得分:0)
您可以使用项目的Resources
类获取所有资源列表。
var set = WindowsFormsApplication1.Properties.Resources.ResourceManager.GetResourceSet(System.Globalization.CultureInfo.CurrentCulture, true, true);
// How do I store images from Resources folder to a List or array?
var resourceList = set.Cast<System.Collections.DictionaryEntry>().Select(item => item.Value);
// How am I supposed to get names of all the images in a list or array?
var nameList = set.Cast<System.Collections.DictionaryEntry>().Select(item => item.Key);
// How do I get names of images with a particular prefix like img1, img2.... ?
var dicResources = set.Cast<System.Collections.DictionaryEntry>().ToDictionary(item => item.Key, item => item.Value);