IsZipFile Method (fileName, testExtract)

DotNetZip

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

This method opens the specified zip file, reads in the zip archive, verifying the ZIP metadata as it reads.

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, as part of its check, this method reads in the content for each entry, expands it, and checks CRCs. This provides an additional check beyond verifying the zip header and directory 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)