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