private void btnRefresh_Click(object sender, EventArgs e) { List <ListViewItem> list = new List <ListViewItem>(); this.lvFiles.Items.Clear(); DirectoryInfo di = new DirectoryInfo(this._directorySource); foreach (FileInfo fi in di.GetFiles("*.xml")) { try { ListViewItem lvi = new ListViewItem(); lvi.Text = fi.Name; string cd, md, rev; o2Mate.Compilateur comp = new o2Mate.Compilateur(); comp.GetHeader(fi.FullName, out cd, out md, out rev); lvi.SubItems.Add(cd); lvi.SubItems.Add(md); lvi.SubItems.Add(rev); list.Add(lvi); } catch { } } list.Sort(new Comparison <ListViewItem>(delegate(ListViewItem l1, ListViewItem l2) { int res = 0; try { if (this.columnSorter == 0) { res = String.Compare(l1.Text, l2.Text); } else if (this.columnSorter == 1) { DateTime dt1 = DateTime.Parse(l1.SubItems[1].Text); DateTime dt2 = DateTime.Parse(l2.SubItems[1].Text); res = DateTime.Compare(dt1, dt2); } else if (this.columnSorter == 2) { DateTime dt1 = DateTime.Parse(l1.SubItems[2].Text); DateTime dt2 = DateTime.Parse(l2.SubItems[2].Text); res = DateTime.Compare(dt1, dt2); } else { Int32 i1 = Int32.Parse(l1.SubItems[3].Text); Int32 i2 = Int32.Parse(l2.SubItems[3].Text); res = i1.CompareTo(i2); } } catch { } return(res); })); foreach (ListViewItem item in list) { this.lvFiles.Items.Add(item); } }