Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 844
nawfal Avatar asked Oct 20 '25 09:10

nawfal


2 Answers

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;
}
like image 96
Taniq Avatar answered Oct 22 '25 03:10

Taniq


public static long GetTotalUnzippedSize(string zipFileName)
{
    using (ZipArchive zipFile = ZipFile.OpenRead(zipFileName))
    {
        return zipFile.Entries.Sum(entry => entry.Length);
    }
}
like image 37
Crulex Avatar answered Oct 22 '25 05:10

Crulex



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!