string[] allFiles = Directory.GetFiles("path/to/dir", "*.*", SearchOption.AllDirectories); string[] txtFiles = Directory.GetFiles("path/to/dir", "*.txt", SearchOption.TopDirectoryOnly);