.netzipsharpcompress

How to delete single entry from ZIP archive using Sharpcompress .net


I'm trying to delete an entry from a ZIP archive, the code i've used is:

 using (var archiveOUT = ZipArchive.Open(tempFilepath, SharpCompress.Common.Options.KeepStreamsOpen, null))
                    {
                        ZipArchiveEntry entryToRemove = archiveOUT.Entries.FirstOrDefault(x => x.FilePath == xlsEntry.FilePath);
                        archiveOUT.RemoveEntry(entryToRemove);
                        archiveOUT.SaveTo(Writer.BaseStream, SharpCompress.Common.CompressionType.Deflate);    
                    }

But when i try to add another file to the created archive using winzip it gives error.

So, is there a correct way to remove an entry using this library?

Thanks in advance


Solution

  • Resolved using latest version of sharpcompress with no code modification. Thanks @alessandrotoro for the hint