Пример #1
0
 private static void DFS(string dirToSearchIn, Folder currentDir)
 {
     try
     {
         //adding all files to current dir
         foreach (var file in Directory.GetFiles(dirToSearchIn))
         {
             currentDir.AddFile(new File(file, new FileInfo(file).Length));
         }
         //adding all childDirs to current dir
         foreach (var dir in Directory.GetDirectories(dirToSearchIn))
         {
             currentDir.AddSubFolder(new Folder(dir));
             DFS(dir, currentDir.ChildFolders[currentDir.ChildFolders.Length - 1]);
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
     }
 }
Пример #2
0
 public void AddSubFolder(Folder folder)
 {
     this.folders.Add(folder);
 }