c# foreach folder in directory code example Example: c# directories loop root.GetDirectories("*.*", System.IO.SearchOption.AllDirectories);