0 votes
by (8.6k points)
edited

I want to create a ZIP file which is password protected.

How to do it using Rebex ZIP?

Applies to: Rebex ZIP

2 Answers

0 votes
by (8.6k points)
edited
 
Best answer

Following C# code shows how to create a password protected ZIP file and add files to it.

// create new ZIP archive 
using (ZipArchive zip = new ZipArchive(@"C:\archive.zip", ArchiveOpenMode.Create))
{
    // set the Password first 
    zip.Password = "PASSword#123";

    // now add all files from the folder c:\data
    zip.Add(@"C:\Data");
}
0 votes
by (8.6k points)
edited

Following VB.NET code shows how to create a password protected ZIP file and ad files to it.

' create new ZIP archive 
Using zip As New ZipArchive("C:\archive.zip", ArchiveOpenMode.Create)
    ' set the Password first 
    zip.Password = "PASSword#123"

    ' now add files from the folder c:\data
    zip.Add("C:\Data")
End Using 
...