DotNetZip does not extract the best compression from WinZip

I created a very simple program in C # using the dotNetZip dll. I am trying to extract a zip file that selects the best compression. Here is the code.

static void Main(string[] args) { string nameOfFile = "testBest.zip"; string directory = "testBest"; Console.WriteLine("Extracting file {0} to {1}", nameOfFile, directory); using (ZipFile zip = ZipFile.Read(nameOfFile)) { foreach (ZipEntry e in zip) { e.Extract(directory, ExtractExistingFileAction.OverwriteSilently); } } } 

And the error says that one of the txt files uses an unsupported compression method.

Can the DotNetZip library not extract zip files when using better compression? Is there any way to handle this? What are the alternatives?

+4
source share
2 answers

I would suggest that the zip compression used is not one of the supported ones. Here is an example forum post where it was like this: http://dotnetzip.codeplex.com/discussions/64680

In this case, DEFLATE64 compression was used instead of DEFLATE, which gave the same error that you see. Although the entire error text will be more useful, it probably does the same thing: the library does not support your compression method.

+3
source

Here I created an extract method. you need to specify the full path to the directory , for example, c: \ temp \ temp.zip

  public void MyExtractZip(string FileName,string Password) { string ExtractLocation = string.Empty; using (ZipFile zip = ZipFile.Read(FileName)) { // here, we extract every entry, but we could extract conditionally // based on entry name, size, date, checkbox status, etc. string ArchiveName =Path.GetFileNameWithoutExtension(FileName); Console.WriteLine("[1] Extract Here [2] Extract too [3] Extract to "+ArchiveName); Console.WriteLine("\n"); Console.Write("Select your option :: \t"); string entry = Console.ReadLine(); int n = int.Parse(entry); string Location =string.Empty; if (n == 2) { Console.Write("Enter the Location ::" ); Location = Console.ReadLine(); } Console.Write("\n"); switch (n) { case 1: ExtractLocation=Path.GetDirectoryName(FileName); break; case 2: ExtractLocation = Location + "\\"; break; case 3: ExtractLocation = Path.GetDirectoryName(FileName) + "\\"+Path.GetFileNameWithoutExtension(FileName); break; } zip.Password = Password; foreach (ZipEntry e in zip) { e.Extract(ExtractLocation, ExtractExistingFileAction.OverwriteSilently); } } } 
0
source

All Articles