C# 批量图片打包下载
实现点击下载功能,可以一次性下载多个附件。具体实现代码如下 :
private void Com_XZTP_FJ(string maiId, string wtfjdz, string CLwtfjdz, string type) { ArrayList all = new ArrayList(); if (!string.IsNullOrEmpty(wtfjdz)) { ArrayList fjarry = spiltBySign(wtfjdz, "|"); all.AddRange(fjarry); } if (!string.IsNullOrEmpty(CLwtfjdz)) { ArrayList wtarry = spiltBySign(CLwtfjdz, "|"); all.AddRange(wtarry); } if (all.Count > 0) { Response.Clear(); Response.ContentType = "application/zip"; Response.AddHeader("content-disposition", "filename=WTPHOTO.zip"); using (ZipFile zip = new ZipFile(System.Text.Encoding.Default))//解决中文乱码问题 { for (int i = 0; i < all.Count; i++) { zip.AddFile(ConfigurationManager.AppSettings["FilePath"].ToString()+ all[i], ""); } zip.Save(Response.OutputStream); } Response.End(); } }
webconfig : <add key="FilePath" value="E:/项目/一厂--生产现场安全监督可视化管理系统/源码/scksh/WebForm"/>
引用第三方dll:Ionic.Zip.dll