2012-06-08 103 views

回答

6

這應該做的伎倆:

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; 
} 
+0

讓我測試它.. – nawfal

+0

感謝,它的工作..其相當快呢..但IM想,如果有可能比迭代更快的方法通過每個條目。 – nawfal

+1

你可以檢查zip.Info屬性,但這需要很長時間,並返回一大堆有用的(?)信息。 – Taniq

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

你能告訴我們這個優點是什麼?或者它與以前的答案有什麼不同? – nawfal

+0

至少,這個版本編譯和工作正常:) – Crulex