4

I have created a very simple program in C# using the DotNetZip dll. I am trying to extract a zip file that chooses 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 one of the txt files uses an unsupported compression method.

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

Mr. Ant
  • 700
  • 2
  • 15
  • 32
  • So, what the question? Yes, the library can have some troubles with unziping. – Evgeny Gavrin May 05 '11 at 15:04
  • 1
    If the DotNetZip Library says in its error message that the format is unsupported, then you probably won't be able to use DotNetZip on those formats...... use some other format that **IS** supported... – marc_s May 05 '11 at 15:48

2 Answers2

3

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

In this case, the compression of DEFLATE64 was used instead of DEFLATE, giving the same error you are seeing. While your entire error text would be more helpful, it will probably come down to the same thing - the library does not support your compression method.

jimhark
  • 4,938
  • 2
  • 27
  • 28
IAmTimCorey
  • 16,412
  • 5
  • 39
  • 75
  • The format being used is PPMd and that is not supported by the DotNetZip library. Thanks for the info! – Mr. Ant May 05 '11 at 16:02
0

hey here i created the extract method. you need to give full path of directory like 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);
                }

            }
        }
Saroop Trivedi
  • 2,245
  • 6
  • 31
  • 49