0

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?

Joe
  • 7,113
  • 1
  • 29
  • 34
Davevmb
  • 85
  • 1
  • 11
  • I don't want to post link-only answer, so I'll paste it as a comment. I think it might be helpfull. http://social.msdn.microsoft.com/Forums/windows/en-US/876b6517-7306-44b0-88df-caebf3b1c10f/add-images-to-listview-control-in-cnet-with-35-frame-work?forum=winforms – Tarec Feb 19 '14 at 11:24
  • 2
    Refer to [this SO](http://stackoverflow.com/questions/5255579/c-sharp-net-windows-forms-listview-with-image-in-detail-view) link. It might help you. – Earth Feb 19 '14 at 11:24
  • Following the info in the reply John posted, i could solve the problem! Thanks for the help! – Davevmb Feb 19 '14 at 11:38

0 Answers0