System.IO.MemoryStream zipFileContents = new System.IO.MemoryStream();
// zip the file
using (System.IO.Compression.ZipArchive zipArchive = new System.IO.Compression.ZipArchive(zipFileContents, System.IO.Compression.ZipArchiveMode::Create, true))
{
foreach( item in list)
{
System.IO.Compression.ZipArchiveEntry fileEntry = zipArchive.CreateEntry( foundryWipCategory.Device +' '+ fileSuf );
System.IO.MemoryStream fileStream = item;
//原文中这里是使用streamReader.ReadToEnd() String中转,可能造成编码问题,除非是纯文本文件,慎用。
using(var s = fileEntry.Open() )
{
fileStream.CopyTo(s);
}
}
}
zipFileContents.Position = 0;
//file::SendFileToUser( this.genFile('8176AL1D'), FileSuf);
file::SendFileToUser(zipFileContents, zipSuf);
refer from