生成可下载图片

        public async Task<FileResult> DownLoad(string name)
        {
            var path = Server.MapPath("~/Templates/") + name;
            using (FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite, 4096, FileOptions.Asynchronous))
            {
                byte[] data = new byte[fs.Length];
                await fs.ReadAsync(data, 0, data.Length);
                return File(data, "application/octet-stream", name);
            }
        }

posted @ 2017-03-15 08:59  爱上-睡觉  阅读(123)  评论(0)    收藏  举报