To extract (unzip) a password protected zip file using the Ionic DotNetZip Library, you can use the snippet below.


[tab name=”C# Sample”]

string zipFile = @"C:\Users\Fesslersoft\Desktop\ZipTest\";
string targetDirectory = @"C:\Users\Fesslersoft\Desktop\ZipTest\";

using (Ionic.Zip.ZipFile zip = Ionic.Zip.ZipFile.Read(zipFile))
	zip.Password = "1234";
	zip.ExtractAll(targetDirectory, Ionic.Zip.ExtractExistingFileAction.DoNotOverwrite);

Console.WriteLine("Zip file has been successfully extracted.");

[tab name=”VB.NET Sample”]

Dim zipFile As String = "C:\Users\Fesslersoft\Desktop\ZipTest\"
Dim targetDirectory As String = "C:\Users\Fesslersoft\Desktop\ZipTest\" 

Using zip As Ionic.Zip.ZipFile = Ionic.Zip.ZipFile.Read(zipFile)
	zip.Password = "1234"
	zip.ExtractAll(targetDirectory, Ionic.Zip.ExtractExistingFileAction.DoNotOverwrite)
End Using

Console.WriteLine("Zip file has been successfully extracted.")



If you have any questions or suggestions feel free to rate this snippet, post a comment or Contact Us via Email.

Related links:

Leave a Reply