Esempio n. 1
0
        public FileBrowser(string rootPhysicalPath, string rootName, params string[] extensions)
        {
            RootPhysicalPath = rootPhysicalPath.ToLower().Replace('/', '\\');
            RootName = rootName;

            _ext = new Dictionary<string, bool>(StringComparer.OrdinalIgnoreCase);
            foreach (string ext in extensions) {
                _ext[ext] = true;
            }

            RootFolder = new FileBrowser_Folder();
            RootFolder.PhysicalPath = RootPhysicalPath;
            RootFolder.RelativePath = RootPhysicalPath.Replace(HttpRuntime.AppDomainAppPath.ToLower(), "").Replace('\\', '/');
            RootFolder.Url = (HttpRuntime.AppDomainAppVirtualPath == "/" ? "" : HttpRuntime.AppDomainAppVirtualPath.TrimEnd('/')) + "/" + RootFolder.RelativePath.Trim('/');
            if (RootFolder.Url == "/")
                RootFolder.Url = "";
        }
Esempio n. 2
0
        public List<FileBrowser_Folder> ListFolders(string relPath)
        {
            if (relPath == null)
                relPath = "";

            string parentFolder = Path.Combine(RootPhysicalPath.Trim('/').Trim('\\'), relPath.Trim('/').Trim('\\'));

            List<FileBrowser_Folder> folders = new List<FileBrowser_Folder>();
            if (!Directory.Exists(parentFolder)) {
                return folders;
            }

            foreach (string folderPath in Directory.GetDirectories(parentFolder)) {
                FileBrowser_Folder folder = new FileBrowser_Folder();
                folder.Name = Path.GetFileName(folderPath);
                folder.PhysicalPath = folderPath;
                folder.RelativePath = folderPath.ToLower().Replace(RootPhysicalPath, "").Replace('\\', '/');
                folder.Url = ResolveUrl(folder.RelativePath);
                folders.Add(folder);
            }

            return folders;
        }