title: DotNetZip creating zip from subset of other zip
body: <p>I have a big zipfile that I need to split in multiple zip files. In the method I'm now creating I have a List object.</p>
  
  <p>This is the code I have got:</p>
  
  <pre><code> //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();
  </code></pre>
  
  <p>And this is the error I get at the save() call :</p>
  
  <blockquote>
    <p>{Ionic.Zlib.ZlibException: Bad state (invalid block type)   at Ionic.Zlib.InflateManager.Inflate(FlushType flush)   at
    Ionic.Zlib.ZlibCodec.Inflate(FlushType flush)   at
    Ionic.Zlib.ZlibBaseStream.Read(Byte[] buffer, Int32 offset, Int32
    count)   at 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()   at
    Ionic.Zip.ZipFile.Save(Stream outputStream)   at </p>
  </blockquote>
  
  <p>What am I doing wrong?</p>