c# get files in directory sorted by name code example Example: Directory.GetFiles sorted by name var sorted = Directory.GetFiles(".").OrderBy(f => f);