IsZipFile Method (stream, testExtract)

DotNetZip

Ionic Zip Library v1.9.1.6 IsZipFile Method (stream, testExtract)
ReferenceIonic.ZipZipFileIsZipFile(Stream, Boolean)
Checks a stream to see if it contains a valid zip archive.
Declaration Syntax
C# Visual Basic Visual C++
public static bool IsZipFile(
	Stream stream,
	bool testExtract
)
Public Shared Function IsZipFile ( _
	stream As Stream, _
	testExtract As Boolean _
) As Boolean
public:
static bool IsZipFile(
	Stream^ stream, 
	bool testExtract
)
Parameters
stream (Stream)
The stream to check.
testExtract (Boolean)
true if the caller wants to extract each entry.
Return Value
true if the stream contains a valid zip archive.
Remarks

This method reads the zip archive contained in the specified stream, verifying the ZIP metadata as it reads. If testExtract is true, this method also extracts each entry in the archive, dumping all the bits into Null.

If everything succeeds, then the method returns true. If anything fails - for example if an incorrect signature or CRC is found, indicating a corrupt file, the the method returns false. This method also returns false for a file that does not exist.

If testExtract is true, this method reads in the content for each entry, expands it, and checks CRCs. This provides an additional check beyond verifying the zip header data.

If testExtract is true, and if any of the zip entries are protected with a password, this method will return false. If you want to verify a ZipFile that has entries which are protected with a password, you will need to do that manually.

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