Ejemplo n.º 1
0
        private long CalculateFolderSize(Folder folder)
        {
            long calculatedSize = 0;
            
            int filesCount = folder.FilesCount;
            if (filesCount > 0)
            {
                for (int id = 0; id < filesCount; id++)
                {
                    calculatedSize += folder.GetFileById(id).Size;
                }
            }

            int subfoldersCount = folder.SubfoldersCount;

            if (subfoldersCount > 0)
            {
                for (int id = 0; id < subfoldersCount; id++)
                {
                    calculatedSize += CalculateFolderSize(folder.GetSubFoldersById(id));
                }
            }

            return calculatedSize;
        }
Ejemplo n.º 2
0
        private long GetFilesSize(Folder folder)
        {
            long size = 0;

            foreach (var file in folder.Files)
            {
                size += file.SizeInBytes;
            }

            foreach (var subFolder in folder.Folders)
            {
                size += subFolder.GetFilesSize();
            }

            return size;
        }
Ejemplo n.º 3
0
        private Folder BrowseForfolderDFS(Folder folder, string folderName)
        {

            Folder foundFolder = null;
            int foldersCount = folder.SubfoldersCount;

            for (int id = 0; id < foldersCount; id++)
            {
                if (this.rootFolder.GetSubFoldersById(id).Name == folderName)
                {
                    foundFolder = this.rootFolder.GetSubFoldersById(id);
                    return foundFolder;
                }

                foundFolder = BrowseForfolderDFS(folder.GetSubFoldersById(id), folderName);
            }

            return foundFolder;
        }
Ejemplo n.º 4
0
 private void AddChildFolders(Folder folder)
 {
     this.childFolders.Add(folder);
 }
Ejemplo n.º 5
0
 public DirectoryTree(string rootPath)
 {
     this.RootPath = rootPath;
     this.rootFolder = new Folder(rootPath);
 }
Ejemplo n.º 6
0
 public RootFolder(string folderPath)
 {
     this.rootFolder = new Folder(folderPath);
 }