Reading and writing Zip files
suggest changeVersions
ZipArchive and ZipFile were added in .NET Framework 4.5 and are covered here through 4.7.
Introduction
The ZipFile and ZipArchive types live in the System.IO.Compression namespace. ZipArchive is in System.IO.Compression.dll. ZipFile is in System.IO.Compression.FileSystem.dll.
Remarks
- You can also use a
MemoryStreaminstead of aFileStream. - The conditions below are for the
ZipArchiveconstructor.
| Exception | Condition |
|---|---|
ArgumentException |
The stream is already closed, or its capabilities do not match the mode (for example, writing to a read-only stream). |
ArgumentNullException |
The input stream is null. |
ArgumentOutOfRangeException |
mode has an invalid value. |
InvalidDataException |
See the list below. |
An InvalidDataException has one of three causes:
- The contents of the stream could not be interpreted as a zip archive.
modeisUpdateand an entry is missing from the archive or is corrupt and cannot be read.modeisUpdateand an entry is too large to fit into memory.
This exception list is taken from the ZipArchive documentation.
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents