// 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; using System.IO; 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(object x, object y) { return String.Compare(((FileInfo)x).Name ,((FileInfo)y).Name); } }