我有一个图像列表,并希望图像的目录添加到图像列表中的我的code。我将如何做到这一点?当我运行code:
I have an image list and would like to add a directory of images to the image list in my code. How would I do this? When I run the code:
'Load all of the items from the imagelist
For Each path As String In Directory.GetFiles("Images\LanguageIcons\")
imlLanguagesIcons.Images.Add(Image.FromFile(path))
Next
我得到一个内存溢出异常。目前只有14的图像所以真的不应该是一个问题。任何帮助吗?
I get an out of memory exception. Currently there is only 14 images so there really shouldn't be a problem. Any Help?
像这样
imageList.Images.Add(someImage);
其中, someImage
是图片
变量。
修改:像这样的:
For Each path As String In Directory.GetFiles("Images\LanguageIcons")
imageList.Images.Add(Image.FromFile(path))
Next