我有一个很大的 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 [] Ionic.Zlib.DeflateStream.Read(Byte[] buffer, Int32 offset, Int32 count) at Ionic.Crc.CrcCalculatorStream.Read(Byte[] buffer, Int32 offset, Int32 count) at Ionic .Zip.SharedUtilities.ReadWithRetry(Stream s, Byte[] buffer, Int32 offset, Int32 count, String FileName) at Ionic.Zip.ZipEntry._WriteEntryData(Stream s) at Ionic.Zip.ZipEntry.Write(Stream s) at Ionic .Zip.ZipFile.Save() 在 Ionic.Zip.ZipFile.Save(Stream outputStream) 在
我究竟做错了什么?