How to find uncompressed size of ionic zip file

后端 未结 2 790
慢半拍i
慢半拍i 2021-01-14 07:15

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

相关标签:
2条回答
  • 2021-01-14 07:32

    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;
    }
    
    0 讨论(0)
  • 2021-01-14 07:40
    public static long GetTotalUnzippedSize(string zipFileName)
    {
        using (ZipArchive zipFile = ZipFile.OpenRead(zipFileName))
        {
            return zipFile.Entries.Sum(entry => entry.Length);
        }
    }
    
    0 讨论(0)
提交回复
热议问题