Update ZipArchive
With RadZipLibrary you can update existing ZIP archive in order to add new entries to it, delete or update existing ones.
The ZipArchive class provides three modes: Read, Create and Update. More information on creating and reading an archive is available here.
The code snippet from Example 1 opens a ZIP archive in update mode using ZipArchive class.
Example 1: Open for update
Add Entry
In order to add a new entry into the ZIP archive, you should perform the following steps:
Use CreateEntry() method of the ZipArchive object to create a new entry.
Open the entry to obtain a stream for writing.
Write the necessary information into the entry.
Dispose entry when all necessary information is written. In the Update mode this step is optional. You can omit it if you are going to add/delete/update other entries in the archive.
More information about ZipArchiveEntry you can find in ZipArchiveEntry help article.
Example 2: Add entry
Delete Entry
The ZipArchive class provides a GetEntry() method, which allows you access to a particular entry in the archive.
Example 3 shows how you could obtain an entry and delete it from the ZIP archive using the Delete() method.
Example 3: Delete entry
Update Entry
In order to update an existing entry in the ZIP archive, you should perform the following steps:
Use GetEntry() method of the ZipArchive object to obtain existing entry.
Open entry to get a stream for reading/writing.
Read/Write the necessary information from/to the entry.
Dispose entry when all necessary information is written. In the Update mode this step is optional. You can omit it if you are going to add/delete/update other entries in the archive.