Articles → .NET → Create password protected zip file using dotnetzip C#

Create password protected zip file using dotnetzip C#






Download DLL





Add a reference to the project





Create a file to zip





Write code to zip file


string filePath = @"c:\temp\Book1.xlsx";
using (FileStream stream = File.Open(filePath, FileMode.Open, FileAccess.Read))
{
       using (ZipFile zip = new ZipFile())
       {
                    zip.Password = "test";                    
                    zip.AddEntry(filePath, stream);
                    zip.Save(Path.GetDirectoryName(filePath) + "\\myZIPFile.zip");                    
       }
}



Click to Enlarge




Posted By  -  Karan Gupta
 
Posted On  -  Thursday, June 11, 2015

Query/Feedback


Your Email Id  
 
Subject 
 
Query/FeedbackCharacters remaining 250