public static void TraverseDirectory(string path) { int initialIdentation = path.Split('\\').Length; Queue <string> subFolders = new Queue <string>(); OutputWriter.WriteMessageOnLine(path); subFolders.Enqueue(path); while (subFolders.Count != 0) { string currentPath = subFolders.Dequeue(); int identation = currentPath.Split('\\').Length - initialIdentation; identation++; foreach (var directoryPath in Directory.GetDirectories(currentPath)) { OutputWriter.WriteMessageOnLine(string.Format("{0}{1}", new string('-', identation), directoryPath)); subFolders.Enqueue(directoryPath); } } }