Ionic.Zip (DotNetZip) hangs in save method using IO.MemoryStream

I will try to create a zip file with DotNetZip-Libary with 106 images (675 MB) 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, execution usually stops at image 40 (sometimes earlier) without any restrictions. Nothing has happened. I tried to save the zip directly to a file. It is working.

Any ideas?

Jan

+4
source share
2 answers

Set the ParallelDeflateThreshold zip object property 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

+11
source

Almost 2 years have passed since the moment of your question, so I doubt that this will help, but I just ran into the same problem in v1.9.1.8.

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

I cannot load the DotNetZip source due to filters at work, but here is a very likely comment from http://dotnetzip.codeplex.com/releases/view/68268

There is a pretty big mistake in the code. I'm working on it. Another guy wrote it in front of me: Dead End in ParallelDeflateOutputStream.EmitPendingBuffers Zipper. At the end of the day I will have to snatch this code and start with a new library. I need to call my last job and give them a head up b / c. I used this library at my last job. They will probably have to snatch the code too. by jnarkiewicz May 30 at 6:31 pm

So, if this is really a problem, increasing the size of these buffers simply reduces the likelihood of a deadlock and is not an ideal solution.

+9
source

Source: https://habr.com/ru/post/1335767/


All Articles