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");
	}
}


Picture showing the password protected zip file created using dotnetzip library in C#
Click to Enlarge




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

Query/Feedback


Your Email Id
 
Subject
 
Query/FeedbackCharacters remaining 250