The ZipWriter and ZipReader classes provides events that let you monitor the progress of the Zip archive creation and extraction processes. Three types of events are available, which are described and demonstrated below.
Event | Description |
---|---|
ByteProgression (writing, reading) | Used to access byte progression information when reading or writing a Zip archive. Available in ZipWriter and ZipReader. |
InvalidPassword | Used when an invalid password is provided. |
The ZipWriter and ZipReader classes both expose a ByteProgression event, which is raised when WriteItemData or ReadItemData is called.
A ZipWriterByteProgressionEventArgs object provides the following properties for use in ZipWriter's ByteProgression event handler:
Property | Description |
---|---|
BytesProcessed | The number of bytes processed of the current file. |
ZipItemLocalHeader | The local header of the item currently being processed. |
A ZipReaderByteProgressionEventArgs object provides the following properties for use in ZipReader's ByteProgression event handler:
Property | Description |
---|---|
BytesProcessed | The number of bytes processed of the current file. |
Percent | The percentage of the current file that has been processed. |
UncompressedSize | The uncompressed size of the current file. |
ZipItemLocalHeader | The local header of the file currently being processed. |
The ZipReader class additionally exposes an InvalidPassword event, which is raised when no password or an invalid password is provided to a password-protected archive. A ZipReaderInvalidPasswordEventArgs object provides the following properties for use in ZipReader's InvalidPassword event handler:
Property | Description |
---|---|
Abort | Indicates whether the Zip read operation should be aborted. |
NewPassword | The new password to be used during the Zip read operation. |
OldPassword | The password initially supplied. |
ZipItemLocalHeader | The local header of the file currently being processed. |
Example 1: Using the ByteProgression event (ZipWriter)
Example 2: Using the ByteProgression and InvalidPassword events (ZipReader)