Advertisement
GlobalAccessSoftware

No Wonder!

Mar 23rd, 2019
522
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.91 KB | None | 0 0
  1.  
  2.     // v4.8.1.78 06-Oct-2018 -JpE-
  3.     // Perfected v4.9.4.90 27-Nov-2018
  4.     private void SortListByLastAccess()
  5.     {
  6.       PFS.Default.SortByAccess = false;
  7.       var sortThese = listBox1.Items
  8.         .Cast<string>().ToList();
  9.       var info = sortThese.Select(
  10.         str => new FileInfo(str)).ToList();
  11.       var sorted = info.OrderBy(
  12.         x => x.LastAccessTime).ToList();
  13.       var list = sorted.Select(fileInfo =>
  14.         fileInfo.FullName).ToList();
  15.       var date = sorted.Select(fileInfo =>
  16.         fileInfo.LastAccessTime).ToList();
  17.       var c = list.Count;
  18.       var list1 = new Collection<string>();
  19.       var date1 = new Collection<string>();
  20.       for (var i = c-1; i >= 0; --i)
  21.       { list1.Add(list[i]);
  22.         date1.Add(Convert.ToString(date[i])); }
  23.       listBox1.Items.Clear();
  24.       foreach (var file in list1)
  25.         listBox1.Items.Add(file);
  26.       GetSelected();
  27.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement