zipEntry.Extract : Cannot read that as a zipfile

Mar 25, 2014 at 10:12 AM
This is my code:
using (var zipFile = String.IsNullOrEmpty(FileName) ? ZipFile.Read((mStream)) : ZipFile.Read(FileName))
            {
                ePubActions eas = new ePubActions(zipFile);
                eas.LoadEpubMetaDataFromOpfFile(eas.opfFilePath);

                foreach (EpubContentItem item in eas.epubContentItems)
                {
                    //Every zipEntry needs te be extracted to a stream:
                    using (MemoryStream stream = new MemoryStream())
                    {
                        ZipEntry ze = zipFile[contentItem];
                        ze.Extract(stream);

... Do some stuff with the extracted file

                        zipFile.RemoveEntry(contentItem);
                        zipFile.AddEntry(contentItem, newStream);
                        MemoryStream tempStream = new MemoryStream();
                        zipFile.Save(tempStream);
                        tempStream.CopyTo(mStream);
                     }
                }
Now, when I reach the Extract method for the second time, a System.ServiceModel.FaultException`1' was thrown with the message "Cannot read that as a zipfile"

This only occurs when the zipfile is read from a stream and when I read the zipfile from an actual file.
Mar 25, 2014 at 10:46 AM
Found the solution myself...

I grabbed the save-part for the zipfile and took it out of the for-each loop