首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >无法使用DotNetZIP压缩大于10 GB的大文件

无法使用DotNetZIP压缩大于10 GB的大文件
EN

Stack Overflow用户
提问于 2017-06-21 09:51:16
回答 1查看 2K关注 0票数 0

我可以压缩多达1GB的文件夹,但我必须压缩超过10 GB。

代码语言:javascript
运行
复制
 string filePath  = C:\Work; // path of the source file 
 private void compressFile(string filePath)
 {
     using (ZipFile zip = new ZipFile())
     {                    
        zip.AddDirectory(Path.Combine(filePath, "Demo"));
        if (File.Exists(Path.Combine(filePath, "Demo.zip")))
        {
           File.Delete(Path.Combine(filePath, "Demo.zip"));
           zip.CompressionLevel = Ionic.Zlib.CompressionLevel.BestCompression;                
           zip.Save(Path.Combine(filePath, "Demo.zip"));                        
         }   

         zip.Save(Path.Combine(filePath, "Demo.zip"));               
       }      
    }
EN

回答 1

Stack Overflow用户

发布于 2017-06-21 09:55:45

我假设这里的问题是内存不足,因为在zip.Save调用之前,所有的东西都在内存中。

建议:不要使用DotNetZIP。如果您使用System.IO.Compression.ZipArchive,那么首先给它一个输出流(在构造函数中)。将其设置为FileStream,而不需要首先缓冲内存中的所有内容。

您需要使用ZipArchiveMode.Create

票数 6
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/44672682

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档