2
Vote

ZipFile.CheckZip fails when using MaxOutputSegmentSize

description

Hello,
 
I'm experiencing a problem when creating a zipfile using the DotNetZip library.
 
This problem occurs when the following 2 conditions are true:
  1. Using the MaxOutputSegmentSize property I set a maximum zip filesize
  2. The total size of created zipfile is smaller then the entered amount and as such only 1 zipfile is created.
     
    The result is that when calling the ZipFile.CheckZip a BadReadException is thrown and I get the message that the created zipfile is not valid.
     
    Example code:
    Using zip = New ZipFile
        zip.AddDirectory("D:\Temp")
        zip.MaxOutputSegmentSize = 1000 * 1024
        zip.Save("d:\test.zip")
    End Using
     
    ZipFile.CheckZip("d:\test.zip")
     
     
    The current solution I have is to only set the MaxOutputSegmentSize if more then 1 file will be created, which is hard to known in advance without zipping everything twice.
     
    Kind regards,
     
    Michael

comments