Search code examples
sizedotnetzipcompression

How to find uncompressed size of ionic zip file


I have a zip file compressed using Ionic zip. Before extracting I need to verify the available disk space. But how do I find the uncompressed size before hand? Is there any header information in the zip file (by ionic) so that I can read it?


Solution

  • This should do the trick:

    Option 1

    static long totaluncompressedsize;
        static string info;
    
        foreach (ZipEntry e in zip) {
            long uncompressedsize = e.UncompressedSize;
            totaluncompressedsize += uncompressedsize;
        }
    

    Or option 2 - will need to sift through the mass of info

    using (ZipFile zip = ZipFile.Read(zipFile)) {
            info = zip.Info;
    }