I'd like to know if there is a better alternative to my following code (preferably using LINQ)
#region List and filter directories to only 3 levels deep
// List all subdirectories within main directory
string[] folders = Directory.GetDirectories(@"C:\pdftest\", "*" ,SearchOption.AllDirectories);
List<string> subdirectories = new List<string>();
//Filter away all main directories, now we are left with subdirectories 3 levels deep
for (int i = 0; i<folders.Length; i++)
{
int occurences = folders[i].Split('\\').Length-1;
if (occurences==4)
subdirectories.Add(folders[i]);
}
#endregion