-->

如何找到离子zip文件的未压缩的大小(How to find uncompressed size o

2019-06-25 07:44发布

我已经使用压缩zip文件离子拉链 。 提取之前,我需要验证可用的磁盘空间。 但我怎么觉得手前的未压缩的大小? 有没有在zip文件(通过离子),这样我可以读取任何头信息?

Answer 1:

这应该做的伎俩:

static long totaluncompressedsize;
static string info;
.
.
.
.

// Option 1
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;
}


Answer 2:

public static long GetTotalUnzippedSize(string zipFileName)
{
    using (ZipArchive zipFile = ZipFile.OpenRead(zipFileName))
    {
        return zipFile.Entries.Sum(entry => entry.Length);
    }
}


文章来源: How to find uncompressed size of ionic zip file