Example #1
0
        public virtual JsonResult Read(string path)
        {
            path = NormalizePath(path);

            if (AuthorizeRead(path))
            {
                try
                {
                    directoryBrowser.Server = Server;

                    var result = directoryBrowser
                                 .GetContent(path, DefaultFilter)
                                 .Select(f => new
                    {
                        name = f.Name,
                        type = f.Type == EntryType.File ? "f" : "d",
                        size = f.Size
                    });

                    return(Json(result, JsonRequestBehavior.AllowGet));
                }
                catch (DirectoryNotFoundException)
                {
                    throw new HttpException(404, "File Not Found");
                }
            }

            throw new HttpException(403, "Forbidden");
        }
        public virtual JsonResult Read(string path)
        {
            //Create root folder if its not exist
            if (!Directory.Exists(GlobalConfigVariable.LetterTemplateImagePath))
            {
                Directory.CreateDirectory(GlobalConfigVariable.LetterTemplateImagePath);
            }

            path = NormalizePath(path);

            if (CanAccess(path))
            {
                try
                {
                    var result = _directoryBrowser
                                 .GetContent(path, DefaultFilter)
                                 .Select(f => new
                    {
                        name = f.Name,
                        type = f.Type == EntryType.File ? FileKey : DirectoryKey,
                        size = f.Size
                    });

                    return(Json(result, JsonRequestBehavior.AllowGet));
                }
                catch (DirectoryNotFoundException)
                {
                    throw new HttpException(404, "File Not Found");
                }
            }
            throw new HttpException(403, "Forbidden");
        }