ComponentOne Zip for .NET
Zip for .NET Task-Based Help / Using Passwords to Protect Zip Files
In This Topic
    Using Passwords to Protect Zip Files
    In This Topic

    To create password-protected zip files, set the Password property to a non-empty string before creating any entries. Each entry may have its own password. For example:

    To write code in Visual Basic

    Visual Basic
    Copy Code
    C1Zip.Password = "password"
    C1Zip.Entries.Add(someFile)
    

    To write code in C#

    C#
    Copy Code
    C1Zip.Password = "password";
    C1Zip.Entries.Add(someFile);
    

    To extract this entry later, the Password property must be set to the same value in effect when the entry was added. For example:

    To write code in Visual Basic

    Visual Basic
    Copy Code
    ' Will fail, password not set.
    C1Zip.Password = ""
    C1Zip.Entries.Extract(someFile)
    ' Will fail, wrong password.
    C1Zip.Password = "pass"
    C1Zip.Entries.Extract(someFile)
     ' Will succeed.
    C1Zip.Password = "password"
    C1Zip.Entries.Extract(someFile)
    

    To write code in C#

    C#
    Copy Code
    // Will fail, password not set.
    C1Zip.Password = "";
    C1Zip.Entries.Extract(someFile);
     // Will fail, wrong password.
    C1Zip.Password = "pass";
    C1Zip.Entries.Extract(someFile);
     // Will succeed.
    C1Zip.Password = "password";
    C1Zip.Entries.Extract(someFile);