public static void TraverseDirectories(string startDirectory, Folder parent, ref List<Folder> folders) { try { Folder folder = new Folder(startDirectory); string[] directories = Directory.GetDirectories(startDirectory); folder.Files = GetFilesInDirectory(startDirectory); foreach (var directory in directories) { TraverseDirectories(directory, folder, ref folders); } if (parent != null) { parent.AddFolder(folder); } folders.Add(folder); } catch (Exception e) { Console.WriteLine(e.Message); } }
public void AddFolder(Folder folder) { this.folders.Add(folder); }