Ejemplo n.º 1
0
        public static Folder GetTreeview()
        {
            if (!DirectoryHelper.Exists(FileBrowser.Config.Settings.Directory.GetUserVirtualDirectory()))
            {
                throw new DirectoryNotFoundException("User directory not found.");
            }

            var rootVirtualPath = FileBrowser.Config.Settings.Directory.GetUserVirtualDirectory().EnsureEndsWith("/").ToLower();
            var rootMappedPath  = PathHelper.ToMappedPath(rootVirtualPath);
            var rootDir         = new DirectoryInfo(rootMappedPath);
            var rootNode        = FolderViewHelper.GetRootTreeviewNode(rootDir);

            foreach (var resource in FileBrowser.Config.Settings.GetResources().OrderBy(x => x.ResourceType))
            {
                if (DirectoryHelper.Exists(string.Concat(rootVirtualPath, resource.ResourceType)))
                {
                    var childVirtualPath = string.Concat(rootVirtualPath, resource.ResourceType).EnsureEndsWith("/").ToLower();
                    var childMappethPath = PathHelper.ToMappedPath(childVirtualPath);
                    var childDir         = new DirectoryInfo(childMappethPath);

                    rootNode.Children.Add(FolderViewHelper.GetChildTreeviewNode(childDir, rootNode, resource, 1));
                }
            }

            return(rootNode);
        }