Пример #1
0
        public virtual JsonResult Read(string target)
        {
            var path = NormalizePath(target);

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

                    var result = directoryProvider
                                 .GetContent(path, DefaultFilter)
                                 .Select(f => new
                    {
                        name           = f.Name,
                        size           = f.Size,
                        path           = ToVirtual(f.Path),
                        extension      = f.Extension,
                        isDirectory    = f.IsDirectory,
                        hasDirectories = f.HasDirectories,
                        created        = f.Created,
                        createdUtc     = f.CreatedUtc,
                        modified       = f.Modified,
                        modifiedUtc    = f.ModifiedUtc
                    });

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

            throw new HttpException(403, "Forbidden");
        }