Exemplo n.º 1
0
        public IActionResult Index(string path)
        {
            string root = conf["gallery"];

            Folder rootFolder = new Folder();

            if (String.IsNullOrEmpty(path))
            {
                rootFolder.SubFolders    = DisplayUtils.GetFolders(env, root);
                rootFolder.Images        = DisplayUtils.GetDisplayImages(env, root);
                rootFolder.CurrentFolder = root;
            }
            else
            {
                string        dirPath = Path.Combine(env.WebRootPath, path);
                DirectoryInfo dirInfo = new DirectoryInfo(dirPath);

                string rootName = dirInfo.Name;
                string parent   = "";
                if (!rootName.Equals(root))
                {
                    string directoryName = Path.GetDirectoryName(dirPath);
                    parent     = directoryName.Substring(directoryName.IndexOf(root));
                    rootFolder = new Folder(rootName, parent);
                }
                else
                {
                    rootFolder = new Folder()
                    {
                        Name          = rootName,
                        CurrentFolder = rootName
                    };
                }

                rootFolder.SubFolders = DisplayUtils.GetFolders(env, path);
                rootFolder.Images     = DisplayUtils.GetDisplayImages(env, path);
            }
            return(View(rootFolder));
        }