Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            string     rootFolderPath = @"C:\Windows\";
            string     rootFolderName = Path.GetDirectoryName(rootFolderPath);
            FolderNode rootFolder     = new FolderNode(rootFolderName);

            rootFolder.GetFilesAndChildFolders();
            Console.WriteLine(rootFolder.FolderSize + " bytes");
            var folder = rootFolder.GetChildFolder(@"C:\Windows\Fonts");

            if (folder == null)
            {
                Console.WriteLine("Folder not found");
            }
            else
            {
                Console.WriteLine(folder.FolderSize + " bytes");
            }
        }
Ejemplo n.º 2
0
        public FolderNode GetChildFolder(string name)
        {
            FolderNode currentFolder = this;
            Dictionary <string, FolderNode> currentChilds = currentFolder.ChildFolders;

            if (currentChilds.ContainsKey(name))
            {
                return(currentChilds[name]);
            }
            else
            {
                foreach (var childFolder in currentChilds.Values)
                {
                    FolderNode result = childFolder.GetChildFolder(name);
                    if (result != null)
                    {
                        return(result);
                    }
                }
            }

            return(null);
        }
Ejemplo n.º 3
0
 public void AddFolder(FolderNode folder)
 {
     this.ChildFolders.Add(folder.Name, folder);
 }