Read Method (zipStream)

DotNetZip

Ionic Zip Library v1.9.1.6 Read Method (zipStream)
ReferenceIonic.ZipZipFileRead(Stream)
Reads a zip archive from a stream.
Declaration Syntax
C# Visual Basic Visual C++
public static ZipFile Read(
	Stream zipStream
)
Public Shared Function Read ( _
	zipStream As Stream _
) As ZipFile
public:
static ZipFile^ Read(
	Stream^ zipStream
)
Parameters
zipStream (Stream)
the stream containing the zip data.
Return Value
The ZipFile instance read from the stream
Remarks

When reading from a file, it's probably easier to just use ZipFile.Read(String, ReadOptions). This overload is useful when when the zip archive content is available from an already-open stream. The stream must be open and readable and seekable when calling this method. The stream is left open when the reading is completed.

Using this overload, the stream is read using the default System.Text.Encoding, which is the IBM437 codepage. If you want to specify the encoding to use when reading the zipfile content, see ZipFile.Read(Stream, ReadOptions). This

Reading of zip content begins at the current position in the stream. This means if you have a stream that concatenates regular data and zip data, if you position the open, readable stream at the start of the zip data, you will be able to read the zip archive using this constructor, or any of the ZipFile constructors that accept a Stream as input. Some examples of where this might be useful: the zip content is concatenated at the end of a regular EXE file, as some self-extracting archives do. (Note: SFX files produced by DotNetZip do not work this way; they can be read as normal ZIP files). Another example might be a stream being read from a database, where the zip content is embedded within an aggregate stream of data.

Examples

This example shows how to Read zip content from a stream, and extract one entry into a different stream. In this example, the filename "NameOfEntryInArchive.doc", refers only to the name of the entry within the zip archive. A file by that name is not created in the filesystem. The I/O is done strictly with the given streams.

CopyC#
using (ZipFile zip = ZipFile.Read(InputStream))
{
   zip.Extract("NameOfEntryInArchive.doc", OutputStream);
}
CopyVB.NET
Using zip as ZipFile = ZipFile.Read(InputStream)
   zip.Extract("NameOfEntryInArchive.doc", OutputStream)
End Using

Assembly: Ionic.Zip (Module: Ionic.Zip) Version: 1.9.1.8 (1.9.1.8)