Exemplo n.º 1
0
        public async static Task <FolderNode> FromPath(string path)
        {
            FolderNode root = new FolderNode()
            {
                Name = path
            };

            root.Paths.Add(new Folder(path));

            await Task.Run(() =>
            {
                root.Subfolders = DrilldownSubfolders(root, path, root.Paths);
            });

            return(root);
        }
Exemplo n.º 2
0
        private static FolderNode[] DrilldownSubfolders(FolderNode parent, string path, List <Folder> paths)
        {
            string[] folders = TryGetDirectories(path);
            paths.AddRange(folders.Select(dir => new Folder(dir)));

            List <FolderNode> subfolders = new List <FolderNode>();

            foreach (string folder in folders)
            {
                FolderNode child = new FolderNode()
                {
                    Name = folder.Split('\\').Last()
                };
                child.Subfolders = DrilldownSubfolders(child, folder, paths);
                subfolders.Add(child);
            }

            return(subfolders.ToArray());
        }