I am trying to load pictures that are in a certain folder (camera) into my application using a listview
and pictureList
. For some reason the files are loaded but do not appear in the listview.
This is the code I have so far:
try
{
listView1.View = View.LargeIcon;
imageList1.ImageSize = new Size(32, 32);
listView1.LargeImageList = imageList1;
DirectoryInfo directory = new DirectoryInfo(@"C:\");
FileInfo[] Archives = directory.GetFiles("*.JPG");
foreach (FileInfo fileinfo in Archives)
{
imageList1.Images.Add(Image.FromFile(fileinfo.FullName));
}
listView1.Update();
MessageBox.Show("I found " + imageList1.Images.Count.ToString() + " images!");
}
catch
{
MessageBox.Show("Something went wrong!");
}
Note that the messagebox is showing me the correct number of files, so I suppose I have some part right. Any clues what might be wrong?