Ionic.Zip (DotNetZip) 在 IO.MemoryStream 的保存方法中挂起
我将尝试使用 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在保存 zip 文件之前将 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 fileREF: http://forums.codeguru.com/showthread.php?534177-Issue-with-DotNetZip-ionic.zip-class-hanging-on-save
你的问题已经过去近两年了,所以我怀疑这会有帮助,但我刚刚在 v1.9.1.8 中遇到了同样的问题。
我通过将 BufferSize 和 CodecBufferSize ZipFile 属性分别增加到 1MB 来解决这个问题。
由于过滤器正在工作,我无法下载 DotNetZip 源代码,但这里有一个来自 http://dotnetzip.codeplex.com/releases/view/68268
因此,如果这确实是问题所在,那么增加这些缓冲区的大小只会降低发生死锁的可能性,并不是理想的解决方案。
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
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.