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