Welcome to the Xceed Community Sign in | Join | Help
Community Search  

How to solve Incompatibility with other compression methods?

Sort Posts: Previous Next
  •  06-19-2008, 4:19 AM Post no. 13074

    How to solve Incompatibility with other compression methods?

    Hi,

    We get an exception when using Xceed Zip RT .Net to open zips created by IP*Works! Zip ver. 6.

    See the full error message and code below.

     Our questions:

    1) How to know which compression method corresponds to each number in the error message?

    What compression methods correspond to the 12336 and 22796 codes in the error message (see below) ?

    2) How to make the Xceed ZipReader class use a custom or external reader when it finds an unknown compression method?

    Code and the full exception message:

            public void UnzipFiles(string zipFileName, string destDir, out string log)
            {
                log = string.Empty;

                //The source Zip archive
                using (FileStream fileStream1 = new FileStream(zipFileName,
                   FileMode.Open, FileAccess.Read))
                {
                    //Must seek to the beginning of the stream before reading.
                    fileStream1.Seek(0, SeekOrigin.Begin);

                    //Create the ZipReader around the stream.
                    Xceed.Zip.ReaderWriter.ZipReader zipReader1 = new
                      Xceed.Zip.ReaderWriter.ZipReader(fileStream1);

                    zipReader1.InvalidPassword += new EventHandler<ZipReaderInvalidPasswordEventArgs>(zipReader_InvalidPassword);               

                    ZipItemLocalHeader zipItemLocalHeader = null;
                    //Read the local headers until no more are found


                    /////////// next line throws the exception!
      //               ZipReader exception
      //               first :            CompressionMethod 12336 not supported by ZipReader.
      //               and other times:   CompressionMethod 22796 not supported by ZipReader.


                    while ((zipItemLocalHeader = zipReader1.ReadItemLocalHeader()) != null)
                    {
                        // sometimes this loop iterates once too often with an "\0\0\0\0" file name
                        // that doesn't exist in the zip archive -
                        // ignore this fake file name
                        if (zipItemLocalHeader.FileName.StartsWith((string)(new string('\0', 1))) &&
                            ! zipItemLocalHeader.IsFolder)
                            continue;
                        log += "\n\r\n file in zip: " + zipItemLocalHeader.FileName;
                        string extratedFileFullName = destDir + @"\\" + zipItemLocalHeader.FileName;
                        FileStream extractedFileStream = new FileStream(extratedFileFullName,
                            FileMode.Create);

                        byte[] buffer = new byte[8192];
                        int read = 0;

                        //Read the item's data until no more is left
                        while ((read = zipReader1.ReadItemData(buffer, 0, buffer.Length)) > 0)
                        {
                            //Do something with the data in 'buffer'
                            extractedFileStream.Write(buffer, 0, buffer.Length);
                        }
                        extractedFileStream.Flush();
                        extractedFileStream.Close();
                    }
                }
            }

    Thanks,

    Ofer

  •  06-20-2008, 3:26 PM Post no. 13120 in reply to 13074

    Re: How to solve Incompatibility with other compression methods?

    1) This means the zip file format of this file is different than the PKWare standard. Can you send us a sample zip file and mention this forum post? This will help us identify what can be wrong with the component.

     

    2) You cannot use an external reader with our component.

     


    André
    Software Developer and Tech Support
    Xceed Software Inc.
View as RSS news feed in XML
Contact | Site Map | Reviews | Legal Terms of Use | Trademarks | Privacy Statement Copyright 2008 Xceed Software Inc.