【发布时间】:2011-12-19 00:59:44
【问题描述】:
我有一个很大的 zip 文件,我需要将其拆分为多个 zip 文件。在我现在创建的方法中,我有一个 List 对象。
这是我得到的代码:
//All files have the same basefilename/
string basefilename = Path.GetFileNameWithoutExtension(entries[0].FileName);
MemoryStream memstream = new MemoryStream();
ZipFile zip = new ZipFile();
foreach (var entry in entries)
{
string newFileName = basefilename + Path.GetExtension(entry.FileName);
zip.AddEntry(newFileName, entry.OpenReader());
}
zip.Save(memstream);
//this will later go in an file-io handler class.
FileStream outstream = File.OpenWrite(@"c:\files\"+basefilename+ ".zip");
memstream.WriteTo(outstream);
outstream.Flush();
outstream.Close();
这是我在调用 save() 时遇到的错误:
{Ionic.Zlib.ZlibException:Ionic.Zlib.InflateManager.Inflate(FlushType flush) 处的错误状态(无效块类型) Ionic.Zlib.ZlibCodec.Inflate(FlushType flush) 在 Ionic.Zlib.ZlibBaseStream.Read(Byte[] 缓冲区,Int32 偏移量,Int32 计数)在 Ionic.Zlib.DeflateStream.Read(Byte[] 缓冲区,Int32 偏移量, Int32 计数)在 Ionic.Crc.CrcCalculatorStream.Read(Byte[] 缓冲区, Int32 偏移量,Int32 计数)在 Ionic.Zip.SharedUtilities.ReadWithRetry(Stream s, Byte[] 缓冲区, Int32 偏移量,Int32 计数,字符串文件名)在 Ionic.Zip.ZipEntry._WriteEntryData(Stream s) 在 Ionic.Zip.ZipEntry.Write(Stream s) at Ionic.Zip.ZipFile.Save() at Ionic.Zip.ZipFile.Save(Stream outputStream) at
我做错了什么?
【问题讨论】:
-
哪一行导致错误?