在线生成压缩文件并下载
using (MemoryStream ms = new MemoryStream()) { using (ZipArchive archive = new ZipArchive(ms, ZipArchiveMode.Update,true)) { string filename = "过程材料.doc"; ZipArchiveEntry readMeEntry = archive.CreateEntry(filename); using (System.IO.Stream stream = readMeEntry.Open()) { doc.Save(stream, SaveFormat.Doc); } } ms.Flush(); ms.Position = 0; //设置编码和附件格式 Response.ContentType = "application/x-zip-compressed"; Response.ContentEncoding = Encoding.UTF8; Response.Charset = ""; Response.AppendHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode(strFileName, Encoding.UTF8)); Response.Clear(); Response.BufferOutput = true; ms.CopyTo(Response.OutputStream); //Response.BinaryWrite(ms.GetBuffer()); Response.End(); }