Exemplo n.º 1
0
 public Folder(string name)
 {
     this.SubFolders = new List<Folder>();
     this.Files = new List<File>();
     this.Name = name;
     this.Parent = null;
 }
Exemplo n.º 2
0
        private void Interate(DirectoryInfo directory, Folder child)
        {
            DirectoryInfo[] subDirectory = directory.GetDirectories();
            Folder[] treeFolder = new Folder[subDirectory.Length];
            if (child != null)
            {
                this.Parent.AddSubFolders(child);
            }


            foreach (var subDir in subDirectory)
            {
               
                child = new Folder(subDir.Name);
                try
                {
                    foreach (var file in subDir.GetFiles())
                    {
                        child.AddFiles(new File(file.Name,file.Length));
                    }
                   
                    this.Interate(subDir,child);
                    
                }
                catch(UnauthorizedAccessException)
                {

                }

                //this.Parent.AddSubFolders(new Folder(subDir.Name));
            }
           
            this.Parent.AddSubFolders(child);
        }
Exemplo n.º 3
0
        private void MakeSum(Folder root)
        {
            List<Folder> subDirectory = root.SubFolders;
            if (subDirectory == null)
            {
                subDirectory[0] = root;
            }
            List<File> directoryFiles;

            for (int currDir = 0; currDir < subDirectory.Count; currDir++)
            {

                directoryFiles = subDirectory[currDir].Files;
                for (int fileIndex = 0; fileIndex < directoryFiles.Count; fileIndex++)
                {
                    this.Sum = this.Sum + directoryFiles[fileIndex].Size;
                }
                this.MakeSum(subDirectory[currDir]);
            }
        }
Exemplo n.º 4
0
 public void AddSubFolders(Folder subFolders)
 {
     this.SubFolders.Add(subFolders);
 }
Exemplo n.º 5
0
 public Tree(Folder root)
 {
     this.Root = root;
 }