private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e) { FileSearch searcher = new FileSearch(); searcher.SearchExtensions.AddRange(new string[] { ".jpg", ".bmp", ".png" }); searcher.Recursive = false; // do not include subfolders!
FileInfo[] files = searcher.Search(folderPath);
ImageList ilist = new ImageList(); listView1.LargeImageList = ilist;
//listView appearance settings ilist.ImageSize = new Size(128, 64); ilist.ColorDepth = ColorDepth.Depth24Bit; ListView_SetSpacing(listView1, 128 + 2, 64 + 30);
for (int i = 0; i < files.GetLength(0); i++) { Image img = Image.FromFile(files[i].FullName); ilist.Images.Add(img.GetThumbnailImage(128, 64, null, new System.IntPtr())); img.Dispose(); ListViewItem lvi = new ListViewItem(files[i].Name); lvi.ImageIndex = i; listView1.Items.Add(lvi); backgroundWorker1.ReportProgress((i*100)/files.Length); } }
|