public FileStream BatchExport()
{
//HttpUtility.UrlEncode是用来解决ie浏览器乱码问题
Response.AddHeader("content-disposition", "attachment;filename="+ HttpUtility.UrlEncode("证件照") + ".zip");//"+ DateTime.Now.ToString("yyyyMMddHHmmss") + "
//Zip文件流 不用using的话会出现文件被占用的情况
using (FileStream zipFile = System.IO.File.Create(Server.MapPath((string)path) + "/证件照.zip"))
{
ZipOutputStream zipStream = new ZipOutputStream(Response.OutputStream);
//循环数据库数据通过fastreport生成文件流并写入压缩文件中,关于fastreport的生成方法省略
foreach (member Info in MemberList)
{
MemoryStream strm = new MemoryStream();
report.Export(new PDFExport(), strm);//PDFExport//ImageExport()
strm.Position = 0;
byte[] bytes = new byte[(int)strm.Length];
strm.Read(bytes, 0, bytes.Length);
strm.Close();
var zipEntry = new ZipEntry(info.id+".pdf");
zipStream.PutNextEntry(zipEntry);
zipStream.SetLevel(5);
zipStream.Write(bytes, 0, bytes.Length);
}
zipStream.Finish();
return zipFile;
}
}
参考网址:
关于文件被占用问题解决方法
https://blog.csdn.net/qq_28215385/article/details/78591973
IE浏览器下载文件中文乱码
https://blog.csdn.net/weiyucai0323/article/details/8255676
导出压缩包到浏览器页面
https://www.cnblogs.com/luna-hehe/p/10101087.html