我使用 DotNetZip 创建一个带有内存字符串的 zip 存档,然后使用以下代码将其作为附件下载。
byte[] formXml = UTF8Encoding.Default.GetBytes("<form><pkg>Test1</pkg></form>");
byte[] formHtml = UTF8Encoding.Default.GetBytes("<html><body>Test2</body></html>");
ZipFile zipFile = new ZipFile();
zipFile.AddEntry("Form.xml", formXml);
zipFile.AddEntry("Form.html", formHtml);
Response.ClearContent();
Response.ClearHeaders();
Response.AppendHeader("content-disposition", "attachment; filename=FormsPackage.zip");
zipFile.Save(Response.OutputStream);
zipFile.Dispose();
现在我需要对 SharpZipLib 做同样的事情。我该怎么做 ?SharpZipLib 是否支持将文件添加为字节数组?