• DotNetZip 压缩下载


    var fs = Response.OutputStream;
                using (ZipFile zip = new ZipFile(System.Text.Encoding.UTF8)) //编码是解决中文问题
                {
                    foreach (var order in orders)
                    {
                        foreach (var orderItem in order.OrderItems)
                        {
                            var filePath = order.Id.ToString("000000");
                            var orderPro = orderItem.Product;
                            if (orderPro != null)
                            {
                                filePath += "/" + orderPro.Name + "_" + string.Join("_", orderPro.ProductDiyAttributes.Select(x=>x.Value))+"("+orderItem.Quantity+")";
                                var printImages =
                                    orderPro.ProductPictures.Where(pp=>!string.IsNullOrEmpty(pp.PrintImageUrl)).Select(x => _webHelper.MapPath(x.PrintImageUrl))
                                        .ToList();
                                zip.AddFiles(printImages,filePath);
                            }
                        }
                    }
                    zip.Save(fs);//保存到输出流
                }
                string fileName = "printimage.zip";
                Response.ContentType = "application/octet-stream";
                Response.AddHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode(fileName, System.Text.Encoding.UTF8));
                //Response.BinaryWrite(bytes);
                Response.Flush();
                Response.End();
  • 相关阅读:
    Codeforces Round #370 (Div. 2)
    Codeforces Round #425 (Div. 2)
    变量调节器
    Smarty基础
    流程
    iframe 内联框架
    权限:改变权限
    权限:查找
    html 框架
    Jcrop+uploadify+php实现上传头像预览裁剪
  • 原文地址:https://www.cnblogs.com/ideacore/p/6289586.html
Copyright © 2020-2023  润新知