SharpDevelop Community

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

Help needed to use "fastzip" class

Last post 12-23-2009 4:37 PM by sergioza. 10 replies.
Page 1 of 1 (11 items)
Sort Posts: Previous Next
  • 12-16-2009 11:42 PM

    Help needed to use "fastzip" class

     Hi,

     

    I wonder if someone knows solution for the following while using "fastzip" class.

    I'm not passing stream but just simply file name to the class method

    myZip.ExtractZip(strSource, strDestin,

    "")

    1. I'm extracting regular files OK using ExtractZip method of the class, but getting an error message for files over 4 gigs

    Error is:

    "Extra data contains Zip64 information but version 2.0 is not high enough"

    Is there a way to fix it?

     

    2. Also, Is there a way to list all files within zipped file using this class easily?

     

    Thank You very Much

  • 12-17-2009 8:09 AM In reply to

    Re: Help needed to use "fastzip" class

    Hi,

    FastZip is limited, and I'd recommend instead using the following code. This gives full control over every aspect.

    using System;
    using System.IO;
    using ICSharpCode.SharpZipLib.Core;
    using ICSharpCode.SharpZipLib.Zip;

    public void ExtractZip() {
        DoExtract(@"c:\temp\Test.zip", null, @"c:\temp\");
    }

    public void DoExtract(string sArchiveIn, string password, string outFolder) {
        ZipFile zf = null;
        try {
            FileStream fs = File.OpenRead(sArchiveIn);
            zf = new ZipFile(fs);
            if (!String.IsNullOrEmpty(password)) {
                zf.Password = password;
            }
            foreach (ZipEntry theEntry in zf) {
                if (!theEntry.IsFile) {
                    continue;            // Ignore directories
                }
                String entryFileName = theEntry.Name;
                // or... String entryFileName = Path.GetFileName(theEntry.Name);

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

                String fullZipToPath = Path.Combine(outFolder, 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);
                }
            }
        } finally {
            if (zf != null) {
                zf.IsStreamOwner = true; // Makes close also shut the underlying stream
                zf.Close(); // Ensure we release resources
            }
        }
    }

  • 12-17-2009 8:12 AM In reply to

    Re: Help needed to use "fastzip" class

    For the list of the contents, keep the code up to

    String entryFileName = theEntry.Name;

    and remove the rest of the for-each. That gives you a lister. You don't need the password to list.

  • 12-17-2009 8:18 AM In reply to

    Re: Help needed to use "fastzip" class

    sergioza:
    "Extra data contains Zip64 information but version 2.0 is not high enough"

    According to the standards, the version must be at least 4.5 to have Zip64. What application created this? Assuming you must deal with some rogue creator progrma over which you have no control, you could just comment out those lines of code in Zip\ZipFile.cs and it should work.

  • 12-17-2009 4:12 PM In reply to

    Re: Help needed to use "fastzip" class

     I don't know which application created it. It's from outside vendor(s). Which line can I uncomment?. I'm just using "dll: with fastzip classs.

     

     

    Thank You

     

     

  • 12-17-2009 11:15 PM In reply to

    Re: Help needed to use "fastzip" class

    Download the source code from the download page
    http://www.icsharpcode.net/OpenSource/SharpZipLib/DownloadLatestVersion.asp?what=SourceSamples

     

    and open Zip\ZipFile.cs

    Comment out these lines ...

                        // Zip64 extra data but 'extract version' is too low
                        if (extractVersion < ZipConstants.VersionZip64)
                        {
                            throw new ZipException(
                                string.Format("Extra data contains Zip64 information but version {0}.{1} is not high enough",
                                extractVersion / 10, extractVersion % 10));
                        }

    Please let us know if that fixes it. If it does you might let the vendor know that they should put version 4.5 or greater in the file if using Zip64.
    Thanks,
    David

  • 12-18-2009 8:39 PM In reply to

    Re: Help needed to use "fastzip" class

     Thank You David,

     

    Unfortunately it doesn't fix it.

     

    It errors in anothe rplace then with zip64 check. If I uncomment still another one it fails

    with "com" error.

     

    Any solution?

     

    Thank You

     

     

  • 12-21-2009 1:31 AM In reply to

    Re: Help needed to use "fastzip" class

    Hi sergioza,

    I'd be happy to have a look at it, if you can get the file to me.

    It goes without saying that all data received is treated with complete confidentiality. I work for a company that deals every day with confidential customer data. Security is our topmost priority here. 

    Depending on the file size, you might like to email it, or if too large, put on an ftp server. Please enclose the file in an encompassing zip with a password, and send me the password separately. Use AES not Zip 2.0 password if it is confidential.

    Best regards,
    David

  • 12-22-2009 5:10 PM In reply to

    Re: Help needed to use "fastzip" class

     Hi David,

    Thank You for you kind offer and help, but I think it got resolved.

    After I commented out zip64 checks in 2 places. I was getting an error:

     

     

    'ContextSwitchDeadlock

    which I thought is a provlem but in reality it was Visual Studio debugging environment problem. I  Marked it Not To Be Triggered Within VS environment

    Thank You

    Sergei

  • 12-23-2009 12:33 AM In reply to

    Re: Help needed to use "fastzip" class

    Hi Sergei,

    Excellent. I will remove that check from the ZipFile class.

    If you could tell me the other place that you commented out to fix it, I will address that too.

    Thanks,
    David

  • 12-23-2009 4:37 PM In reply to

    Re: Help needed to use "fastzip" class

     Commented out:

     

    // TODO Check for tag values being distinct.. Multiple zip64 tags means what?

     

     

     

     

     

     

     

     

     

     

     

     

    // Zip64 extra data but 'extract version' is too low

     

     

    if (extractVersion < ZipConstants

    .VersionZip64)

    {

     

     

    //sz - commented out

     

     

    // throw new ZipException(

     

     

    // string.Format("Extra data contains Zip64 information but version {0}.{1} is not high enough",

     

     

    // extractVersion / 10, extractVersion % 10));

    }

     

     

    //sz Commneteout

     

     

    // Zip64 extra data but size fields dont indicate its required.

     

     

    if (((uint)size != uint.MaxValue) && ((uint)compressedSize != uint

    .MaxValue))

    {

     

     

    // throw new ZipException("Entry sizes not correct for Zip64");

    }

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