SharpDevelop Community

Get your problems solved!
Welcome to SharpDevelop Community Sign in | Join | Help
in Search

OLD PKZip compatibility

Last post 02-18-2009 10:45 PM by DavidPierson. 1 replies.
Page 1 of 1 (2 items)
Sort Posts: Previous Next
  • 02-18-2009 7:50 PM

    OLD PKZip compatibility

    Hihi ;)

    I am currently working with a company whos software uses a VERY old (like 14 years or so) pkzip library to compress data streams and combine them into concurrent records in a proprietary files.

    I was wondering if #ZipLib would be capable of decompressing a bytestream that is compressed in pkzip format that is as old as that.  We're trying to find a solution that would allow us to avoid the hoops and hacks needed to use this old library through our .NET application.

    We're trying to move our new development into the future while not rendering our old data obsolete.

     

    Thank you in advance

    James

  • 02-18-2009 10:45 PM In reply to

    Re: OLD PKZip compatibility

     Hi James

    I am old enough to have used PKZip and I would have thought that Winzip and PKZip formats are sufficiently compatible. I don't hear much from PKZip these days but Phil Katz did a good job of setting an open standard.

    These are the comments from the Version property in SharpZip. It certainly supports PkzipClassic encryption. 

     Minimum features are defined as:
    1.0 - Default value
    1.1 - File is a volume label
    2.0 - File is a folder/directory
    2.0 - File is compressed using Deflate compression
    2.0 - File is encrypted using traditional encryption
    2.1 - File is compressed using Deflate64
    2.5 - File is compressed using PKWARE DCL Implode
    2.7 - File is a patch data set
    4.5 - File uses Zip64 format extensions
    4.6 - File is compressed using BZIP2 compression
    5.0 - File is encrypted using DES
    5.0 - File is encrypted using 3DES
    5.0 - File is encrypted using original RC2 encryption
    5.0 - File is encrypted using RC4 encryption
    5.1 - File is encrypted using AES encryption
    5.1 - File is encrypted using corrected RC2 encryption
    5.1 - File is encrypted using corrected RC2-64 encryption
    6.1 - File is encrypted using non-OAEP key wrapping
    6.2 - Central directory encryption (not confirmed yet)
    6.3 - File is compressed using LZMA
    6.3 - File is compressed using PPMD+
    6.3 - File is encrypted using Blowfish
    6.3 - File is encrypted using Twofish

    To get you going here is some basic code to extract to the c:\temp folder, you may need to adjust that line. 

    private void DoExtract(string sArchive) {
        ZipFile zf = null;
        try {
            zf = new ZipFile(File.OpenRead(sArchive));
            zf.Password = "whatever"; // if needed

            foreach (ZipEntry theEntry in zf) {
                String entryFileName = Path.GetFileName(theEntry.Name);

                byte[ buffer = new byte[4096];
                Stream zipStream = zf.GetInputStream(theEntry);

                String fullZipToPath = Path.Combine(@"c:\temp\", entryFileName);
                // unzip file in buffered chunks
                // the "using" will close the stream even if an exception occurs
                using (FileStream streamWriter = File.Create(fullZipToPath)) {
                    StreamUtils.Copy(zipStream, streamWriter, buffer);
                }
            }
        }
        catch (Exception ex) {
            throw new Exception(ex.Message + " (extracting from zipfile " + Path.GetFileName(sArchive) + ")");
        } finally {
            if (zf != null) {
                zf.IsStreamOwner = true; // Makes close also shut the underlying stream
                zf.Close(); // Ensure we release resources
            }
        }
    }

    Regards

    David

     

Page 1 of 1 (2 items)
Powered by Community Server (Commercial Edition), by Telligent Systems
Don't contact us via this (fleischfalle@alphasierrapapa.com) email address.