Password Property

DotNetZip

Ionic Zip Library v1.9.1.6 Password Property
ReferenceIonic.ZipZipInputStreamPassword
Sets the password to be used on the ZipInputStream instance.
Declaration Syntax
C# Visual Basic Visual C++
public string Password { set; }
Public WriteOnly Property Password As String
	Set
public:
property String^ Password {
	void set (String^ value);
}
Remarks

When reading a zip archive, this password is used to read and decrypt the entries that are encrypted within the zip file. When entries within a zip file use different passwords, set the appropriate password for the entry before the first call to Read() for each entry.

When reading an entry that is not encrypted, the value of this property is ignored.

Examples
This example uses the ZipInputStream to read and extract entries from a zip file, using a potentially different password for each entry.
CopyC#
byte[] buffer= new byte[2048];
int n;
using (var raw = File.Open(_inputFileName, FileMode.Open, FileAccess.Read ))
{
    using (var input= new ZipInputStream(raw))
    {
        ZipEntry e;
        while (( e = input.GetNextEntry()) != null)
        {
            input.Password = PasswordForEntry(e.FileName);
            if (e.IsDirectory) continue;
            string outputPath = Path.Combine(_extractDir, e.FileName);
            using (var output = File.Open(outputPath, FileMode.Create, FileAccess.ReadWrite))
            {
                while ((n= input.Read(buffer,0,buffer.Length)) > 0)
                {
                    output.Write(buffer,0,n);
                }
            }
        }
    }
}

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