Resource files are a very useful addition to the .NET framework as they allow easy storage and retrival of data e.g.
1 2 3 |
MyResourceFile.Image1; MyResourceFile.Image2; ... |
In order to iterate through the all the resources in the resource file, we have to use ResourceSet
. To get it we need run a resource manager on our resource file. The complete example can be found below:
1 2 3 4 5 6 7 |
ResourceSet myResourceSet = MyResourceFile.ResourceManager.GetResourcesSet(CultureInfo.CurrentUICulture, true, ture); foreach (DictionaryEntry entry in myResourceSet) { string imageKey = entry.Key.ToString(); Bitmap image = entry.Value as Bitmap; // .. do whatever you need to with this info. } |