Ionic.Zip.ZipInputStream.ZipInputStream C# (CSharp) Method

ZipInputStream() public method

Create a ZipInputStream, wrapping it around an existing stream.

While the ZipFile class is generally easier to use, this class provides an alternative to those applications that want to read from a zipfile directly, using a System.IO.Stream.

Both the ZipInputStream class and the ZipFile class can be used to read and extract zip files. Both of them support many of the common zip features, including Unicode, different compression levels, and ZIP64. The programming models differ. For example, when extracting entries via calls to the GetNextEntry() and Read() methods on the ZipInputStream class, the caller is responsible for creating the file, writing the bytes into the file, setting the attributes on the file, and setting the created, last modified, and last accessed timestamps on the file. All of these things are done automatically by a call to ZipEntry.Extract(). For this reason, the ZipInputStream is generally recommended for when your application wants to extract the data, without storing that data into a file.

Aside from the obvious differences in programming model, there are some differences in capability between the ZipFile class and the ZipInputStream class.

ZipFile can be used to create or update zip files, or read and extract zip files. ZipInputStream can be used only to read and extract zip files. If you want to use a stream to create zip files, check out the . ZipInputStream cannot read segmented or spanned zip files. ZipInputStream will not read Zip file comments. When reading larger files, ZipInputStream will always underperform ZipFile. This is because the ZipInputStream does a full scan on the zip file, while the ZipFile class reads the central directory of the zip file.
public ZipInputStream ( Stream stream ) : System
stream Stream /// The stream to read. It must be readable. This stream will be closed at /// the time the ZipInputStream is closed. ///
return System
        public ZipInputStream(Stream stream)  : this (stream, false) { }

Same methods

ZipInputStream::ZipInputStream ( Stream stream, bool leaveOpen ) : System
ZipInputStream::ZipInputStream ( String fileName ) : System