private void BTN_RemoveItems_Click(object sender, EventArgs e) { LB_FilesToPak.BeginUpdate(); IEnumerable <string> FilesToRemove = LB_FilesToPak.SelectedItems.Cast <string>(); foreach (string FileName in FilesToRemove) { LB_FilesToPak.Items.Remove(FileName); } LB_FilesToPak.EndUpdate(); }
private void LB_FilesToPak_DragDrop(object sender, DragEventArgs e) { LB_FilesToPak.BeginUpdate(); string[] FileNames = e.Data.GetData(DataFormats.FileDrop, false) as string[]; foreach (string FileName in FileNames.Where(FileName => !LB_FilesToPak.Items.Contains(FileName))) { if (IsDirectory(FileName)) { foreach (string SubDirFileName in Directory.EnumerateFiles(FileName, "*.*", SearchOption.AllDirectories) .Where(SubDirFileName => !LB_FilesToPak.Items.Contains(SubDirFileName))) { LB_FilesToPak.Items.Add(SubDirFileName); } } else { LB_FilesToPak.Items.Add(FileName); } } LB_FilesToPak.EndUpdate(); }