获取数组中的所有资源 [英] Get all resources in array

查看:103
本文介绍了获取数组中的所有资源的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个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.

这篇关于获取数组中的所有资源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆