看了几个例子,按照这些例子我的代码现在看起来像这样(见下文),但不幸的是我收到错误“'System.Windows.Forms.ImageList'不包含'toArray'的定义并且没有扩展名可以找到接受“System.Windows.Forms.ImageList”类型的第一个参数的方法“toArray”(您是否缺少 using 指令或程序集引用?)”
有任何想法吗 ?我可能错过了其他帖子中显示的部分,但我不这么认为
ImageList Move_list = new ImageList();
.
.
.
//Gather the images
string path = "C:/Pictures/Movements/User";
string[] filter = { ".jpg", ".jpeg"};
DirectoryInfo directoryInfo = new DirectoryInfo(path);
FileInfo[] fileInfo = directoryInfo.GetFiles();
ArrayList arrayList = new ArrayList();
foreach (FileInfo fi in fileInfo)
foreach (string s in filter)
if (s == fi.Extension)
arrayList.Add(fi.FullName);
//adding files to image list:
for (i = 0; i < arrayList.Count; i++)
{
System.Drawing.Image img = System.Drawing.Image.FromFile(arrayList[i].ToString());
Move_list.Images.Add(img);
}
User_moves[0] = Move_list.toArray();