Ionic Zip Library v1.9.1.6
RemoveEntry Method (fileName)
Removes the ZipEntry with the given filename from the zip archive.
Declaration Syntax
Parameters
- fileName (String)
- The name of the file, including any directory path, to remove from the zip. The filename match is not case-sensitive by default; you can use the CaseSensitiveRetrieval property to change this behavior. The pathname can use forward-slashes or backward slashes.
Remarks
After calling RemoveEntry, the application must call Save to make the changes permanent.
Examples
This example shows one way to remove an entry with a given filename from
an existing zip archive.
CopyC#
String zipFileToRead= "PackedDocuments.zip"; string candidate = "DatedMaterial.xps"; using (ZipFile zip = ZipFile.Read(zipFileToRead)) { if (zip.EntryFilenames.Contains(candidate)) { zip.RemoveEntry(candidate); zip.Comment= String.Format("The file '{0}' has been removed from this archive.", Candidate); zip.Save(); } }
CopyVB.NET
Dim zipFileToRead As String = "PackedDocuments.zip" Dim candidate As String = "DatedMaterial.xps" Using zip As ZipFile = ZipFile.Read(zipFileToRead) If zip.EntryFilenames.Contains(candidate) Then zip.RemoveEntry(candidate) zip.Comment = String.Format("The file '{0}' has been removed from this archive.", Candidate) zip.Save End If End Using
Exceptions
Exception | Condition |
---|---|
InvalidOperationException |
Thrown if the ZipFile is not updatable.
|
ArgumentException |
Thrown if a ZipEntry with the specified filename does not exist in
the ZipFile.
|