Ionic.Zip (DotNetZip) 在 IO.MemoryStream 的保存方法中挂起

发布于 2024-10-12 00:45:32 字数 616 浏览 6 评论 0原文

我将尝试使用 DotNetZip-Libary 创建一个包含 106 个图像 (675MB) 的 zip 文件,代码如下:

Public Function GetZip() As Byte()
    Dim zip As New Ionic.Zip.ZipFile(String.Format("{0}.zip", Me.GallerySystemName))
    AddHandler zip.SaveProgress, AddressOf SaveProgress

    For Each img In Me.Images
        zip.AddFile(img.OriginalFile.FullName, "")
    Next

    Dim bytZip As Byte()

    Using ms As New MemoryStream
        zip.Save(ms)
        bytZip = ms.ToArray
    End Using

    Return bytZip
End Function

当我运行此代码时,执行通常会在图像 40(有时更早)处停止,没有任何例外。什么也没发生。我尝试将 zip 直接保存到文件中。有用。

有什么想法吗?

I'll try to create an zip file with the DotNetZip-Libary with 106 Images (675MB) with the following code:

Public Function GetZip() As Byte()
    Dim zip As New Ionic.Zip.ZipFile(String.Format("{0}.zip", Me.GallerySystemName))
    AddHandler zip.SaveProgress, AddressOf SaveProgress

    For Each img In Me.Images
        zip.AddFile(img.OriginalFile.FullName, "")
    Next

    Dim bytZip As Byte()

    Using ms As New MemoryStream
        zip.Save(ms)
        bytZip = ms.ToArray
    End Using

    Return bytZip
End Function

When I run this code, the execution stops usally at image 40 (sometimes earlier) without any exeption. Nothing happens. I tried to save the zip directly to a file. It works.

Any ideas?

Jan

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

傲鸠 2024-10-19 00:45:32

在保存 zip 文件之前将 zip 对象属性 ParallelDeflateThreshold 设置为 -1

zip.ParallelDeflateThreshold = -1

参考:http://forums.codeguru。 com/showthread.php?534177-Issue-with-DotNetZip-ionic.zip-class-hanging-on-save

SET the zip object property ParallelDeflateThreshold to -1 just before saving the zip file

zip.ParallelDeflateThreshold = -1

REF: http://forums.codeguru.com/showthread.php?534177-Issue-with-DotNetZip-ionic.zip-class-hanging-on-save

墨小沫ゞ 2024-10-19 00:45:32

你的问题已经过去近两年了,所以我怀疑这会有帮助,但我刚刚在 v1.9.1.8 中遇到了同样的问题。

我通过将 BufferSizeCodecBufferSize ZipFile 属性分别增加到 1MB 来解决这个问题。

由于过滤器正在工作,我无法下载 DotNetZip 源代码,但这里有一个来自 http://dotnetzip.codeplex.com/releases/view/68268

代码中有一个相当大的错误。我正在努力弄清楚。另一个小伙子在我之前记录了它:ParallelDeflateOutputStream.EmitPendingBuffers 中的死锁 zip 挂起。一天结束时,我将不得不撕掉这段代码并从一个新的库开始。我需要打电话给我的上一份工作并提醒他们,因为我在上一份工作中使用了这个库。他们可能也必须撕掉代码。
作者:jnarkiewicz,5 月 30 日下午 6:31

因此,如果这确实是问题所在,那么增加这些缓冲区的大小只会降低发生死锁的可能性,并不是理想的解决方案。

It's been almost 2 years since your question, so I doubt this will help but I just encountered the same problem in v1.9.1.8.

I worked around it by increasing the BufferSize and CodecBufferSize ZipFile properties to 1MB each.

I can't download the DotNetZip source because of filters at work but here is a very-likely-related comment from http://dotnetzip.codeplex.com/releases/view/68268

There is a pretty major bug in the code. I am working to figure it out. Another chap logged it before me: Deadlock in ParallelDeflateOutputStream.EmitPendingBuffers The zip hangs. End-of-day I will have to rip this code out and start over with a new library. I need to call my last job and give them a head's up b/c I used this library at my last job. They will likely have to rip the code out too.
by jnarkiewicz on May 30 at 6:31 PM

So if this is indeed the problem, increasing the size of those buffers just lowers the likelihood of the deadlock occurring and is not an ideal solution.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文