// Collection of code snippets by Arne Vajhøj // (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) using System; using System.Collections.Generic; using System.IO; public class TestClass { public static void Main(string[] args) { DirectoryInfo di = new DirectoryInfo(@"C:\"); FileInfo[] fi = di.GetFiles(); for(int i = 0; i < fi.Length; i++) { Console.WriteLine(fi[i].Name); } Array.Sort(fi, new FileInfoComparer()); for(int i = 0; i < fi.Length; i++) { Console.WriteLine(fi[i].Name); } } } public class FileInfoComparer : IComparer { public int Compare(FileInfo x, FileInfo y) { return x.CreationTime.CompareTo(y.CreationTime); } }