C# Examples

ChilkatHOMEAndroid™ASPVisual BasicVB.NETC#iOS (IPhone)Objective-CC++CMFCDelphiFoxProJavaPerl
PHP ExtensionPHP ActiveXPythonPowerShellRubySQL ServerVBScript

C# Examples

Bounced Mail
Bz2
Character Encoding
CSV
DKIM / DomainKey
Digital Certificates
Digital Signatures
Email
Email Object
FTP
HTML Conversion
HTTP
IMAP
Encryption
MHT / HTML Email
MIME
POP3
RSA
S/MIME
SMTP
Socket
Spider
SSH
SSH Tunnel
SSH Key
SFTP
Tar Archive
Upload
XML
XMP
Zip Compression


More Examples...
Amazon S3
NTLM
FileAccess
RSS
Atom
String
Byte Array
Self-Extractor
Service
PPMD
Deflate
DH Key Exchange
DSA
Bzip2
LZW

 

 

 

 

 

 

Determine if Zip is Encrypted or Password Protected

Download: Chilkat .NET Assemblies

C# example program to determine if a .zip is password-protected or WinZip AES encrypted.

// This example discusses how to determine if a Zip is 
// password-protected or WinZip AES encrypted.
Chilkat.Zip zip = new Chilkat.Zip();
zip.UnlockComponent("Anything for 30-day trial");

string zipFilename = "myZip.zip";

// Password-protected Zips cannot be opened without 
// first providing the password.
// Therefore, there is a method available to test a .zip
// for this condition:
bool isPwdProtected = zip.IsPasswordProtected(zipFilename);
if (isPwdProtected)
{
    MessageBox.Show("This zip is password-protected and requires a password to open.");
    return;
}

// WinZip AES encrypted zips can technically be opened 
// without first providing a password.  That is because 
// the encryption occurs on a per-entry basis within the
// zip.  It is possible that some files within the zip
// may be encrypted, and others not.  It is also possible
// that some files within the zip may be encrypted differently
// or with different passwords.  It is generally not possible
// to mix older Zip 2.0 encryption (password-protected) with WinZip
// AES encryption.
bool success = zip.OpenZip(zipFilename);
if (!success) 
{
    MessageBox.Show(zip.LastErrorText);
    return;
}

// If an entry's compression method = 99, it is AES encrypted.
// Your application may decide to check only the 1st entry within
// the zip, or all of them:

// To check the 1st entry:
Chilkat.ZipEntry entry = zip.GetEntryByIndex(0);
if (entry.CompressionMethod == 99) 
{
    MessageBox.Show("This zip is WinZip AES strong encrypted!");
    return;
}

// To check all the entries within the zip:
int i;
int n = zip.NumEntries;
for (i=0; i<n; i++)
{
    entry = zip.GetEntryByIndex(i);
    if (entry.CompressionMethod == 99) 
    {
	MessageBox.Show("This zip is WinZip AES strong encrypted!");
	return;
    }
}

MessageBox.Show("We got here, so the Zip is not encrypted!");	    


Important: The download for this example does not contain the ChilkatDotNet.dll which
must be downloaded and installed separately at http://www.chilkatsoft.com/downloads.asp.
Once installed, add a reference to the DLL in the project by following the instructions at
http://www.example-code.com/csharp/step2.asp

 

© 2000-2012 Chilkat Software, Inc. All Rights Reserved.

Email Component · XML Parser