Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.IO;
- using System.Text;
- namespace BashSoft
- {
- public static class IOManager
- {
- public static void TraverseDirectory(string path)
- {
- OutputWritter.WriteEmptyLine();
- int initialIdentation = path.Split('\\').Length;
- Queue<string> subFolders = new Queue<string>();
- subFolders.Enqueue(path);
- var subdirectory = Directory.GetDirectories(path);
- OutputWritter.WriteOnNewLine(subFolders.Dequeue());
- foreach (var item in subdirectory)
- {
- subFolders.Enqueue(item);
- }
- while (subFolders.Count !=0)
- {
- string currentPath = subFolders.Dequeue();
- int identation = currentPath.Split('\\').Length - initialIdentation;
- var tempDir = Directory.GetDirectories(currentPath);
- if (tempDir.Length > 0)
- {
- subFolders.Enqueue(tempDir[0]);
- OutputWritter.WriteOnNewLine(string.Format("{0}{1}", new string('-', identation), currentPath));
- }
- else
- {
- OutputWritter.WriteOnNewLine(string.Format("{0}{1}", new string('-', identation), currentPath));
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment