Get all resources in array
I have a VB.NET program with lots of embedded resources which are images. Is there a way to get all the resources in an array so I can acces them in a for loop?
I currently have to do it this way:
images(1) = My.Resources.image1
images(2) = My.Resources.image2
'...
i开发者_运维百科mages(80) = My.Resources.image80
Something like this perhaps:
Dim ResourceSet As Resources.ResourceSet = My.Resources.ResourceManager.GetResourceSet(Globalization.CultureInfo.CurrentCulture, True, True)
For Each Dict As DictionaryEntry In ResourceSet.OfType(Of Object)()
If TypeOf (Dict.Value) Is Drawing.Image Then
Debug.WriteLine(Dict.Key) 'outputting resource name
(Do stuff here)
End If
Next
It appears that the key is the name of the resource.
精彩评论