2010-04-22 63 views

回答

0

你不能这样做只是使用GZipStream。您需要执行ZIP标准,例如#ziplib。从MSDN报价:

书面 到一个文件中以.gz的扩展,可以使用 许多常见 压缩工具进行解压压缩GZipStream对象;但是,此类 本身不提供用于向文件添加文件的 功能或从.zip文件中提取文件的 。

例与#ziplib:

using (var stream = File.OpenRead("test.zip")) 
using (var zipStream = new ZipInputStream(stream)) 
{ 
    ZipEntry entry; 
    while ((entry = zipStream.GetNextEntry()) != null) 
    { 
     // entry.IsDirectory, entry.IsFile, ... 
     Console.WriteLine(entry.Name); 
    } 
} 
+0

能否请你解释一下? – 2010-04-22 10:02:28