Beispiel #1
0
        public ActionResult Handle(string path, string[] items, string toFilename)
        {
            path = path?.TrimStart('\\', '/') ?? "";
            var root = CommonHelper.SystemSettings["PathRoot"].TrimStart('\\', '/');
            var file = Path.Combine(_hostingEnvironment.ContentRootPath, root, path);

            switch (Request.Query["action"])
            {
            case "download":
                if (System.IO.File.Exists(file))
                {
                    return(this.ResumePhysicalFile(file, Path.GetFileName(file)));
                }
                break;

            case "downloadMultiple":
                byte[] buffer = _sevenZipCompressor.ZipStream(items.Select(s => Path.Combine(_hostingEnvironment.ContentRootPath, root, s.TrimStart('\\', '/'))).ToList()).ToArray();
                return(this.ResumeFile(buffer, Path.GetFileName(toFilename)));
            }
            return(Content("null"));
        }
        public ActionResult Handle(string path, string[] items, string toFilename)
        {
            var prefix = CommonHelper.SystemSettings["PathRoot"].Trim('\\', '/');

            switch (Request.Query["action"])
            {
            case "download":
                string file = string.IsNullOrEmpty(prefix) && !Directory.Exists(prefix) ? _hostingEnvironment.WebRootPath + (path) : prefix + path;
                //_hostingEnvironment.WebRootPath + (path);
                if (System.IO.File.Exists(file))
                {
                    return(this.ResumePhysicalFile(file, Path.GetFileName(file)));
                }
                break;

            case "downloadMultiple":
                byte[] buffer = _sevenZipCompressor.ZipStream(items.Select(s => string.IsNullOrEmpty(prefix) && !Directory.Exists(prefix) ? _hostingEnvironment.WebRootPath + (s) : prefix + s).ToList()).ToArray();
                return(this.ResumeFile(buffer, Path.GetFileName(toFilename)));
            }
            return(Content("null"));
        }