【发布时间】:2018-08-07 05:18:37
【问题描述】:
我已经编写了如下方法将多个 Memorystream 绑定到 ziparchive。该代码适用于一个流,但如果我通过迭代添加多个流,则会在 for 循环的第二行显示以下错误。
System.IO.IOException: 'Entries cannot be created
while previously created entries are still open.'
我的代码,
using (var zip = new ZipArchive(outputStream, ZipArchiveMode.Create,
leaveOpen: false))
{
for (int i = 0; i < msList.Count; i++)
{
msList[i].Position = 0;
var createenter = zip.CreateEntry("123"+i+".jpg",
CompressionLevel.Optimal);
msList[i].CopyTo(createenter.Open());
}
}
【问题讨论】:
标签: c# memorystream ziparchive