我有一个VB.NET程序有很多的嵌入式资源,这是图像。有没有办法让所有的资源在一个数组,所以我可以在他们的存取权限的循环?
我现在要做的是这样的:
图像(1)= My.Resources.image1
图像(2)= My.Resources.image2
'...
图像(80)= My.Resources.image80
解决方案
这样的事情也许是:
昏暗的ResourceSet作为Resources.ResourceSet = My.Resources.ResourceManager.GetResourceSet(Globalization.CultureInfo.CurrentCulture,真,真)
对于每一个字典作为的DictionaryEntry在ResourceSet.OfType(对象)()
如果TypeOf运算(Dict.Value)是Drawing.Image然后
的Debug.WriteLine(Dict.Key)输出资源名称
(做的东西在这里)
结束如果
下一个
似乎关键是资源的名称
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
'...
images(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.