Unzipping : Cannot read that as a ZipFile : An item with the same key has already been added.

May 9, 2012 at 10:20 AM

I get an exception when running this code:
    Private Sub unzipit()
        Using zip As ZipFile = ZipFile.Read(which)
            Dim ee As ZipEntry
            '  ProgressBar2.Maximum = ee.EmitTimesInUnixFormatWhenSaving
            For Each ee In zip
                ee.Extract(destination, ExtractExistingFileAction.OverwriteSilently)
            Next
        End Using
        ProgressBar2.Value = ProgressBar2.Maximum

This is the exception. I have two duplicate files in the zip. I thought 

OverwriteSilently would solve this but it doesn't. Any suggestions as how to over come this?

thanks.




Ionic.Zip.ZipException was unhandled by user code
  Message=Cannot read that as a ZipFile
  Source=Ionic.Zip
  StackTrace:
       at Ionic.Zip.ZipFile.ReadIntoInstance(ZipFile zf)
       at Ionic.Zip.ZipFile.Read(String fileName, TextWriter statusMessageWriter, Encoding encoding, EventHandler`1 readProgress)
       at Ionic.Zip.ZipFile.Read(String fileName)
       at RadarBox_Resources.Form1.unzipit() in C:\Users\xxx\Dropbox\Code\VB\R-Resources\R-Resources\Form1.vb:line 62
       at RadarBox_Resources.Form1.downloadFile_ProgressChanged(Object sender, DownloadProgressChangedEventArgs e) in C:\Users\xxx\Dropbox\Code\VB\R-Resources\R-Resources\Form1.vb:line 57
       at System.Net.WebClient.OnDownloadProgressChanged(DownloadProgressChangedEventArgs e)
       at System.Net.WebClient.ReportDownloadProgressChanged(Object arg)
  InnerException: System.ArgumentException
       Message=An item with the same key has already been added.
       Source=mscorlib
       StackTrace:
            at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource)
            at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)
            at System.Collections.Generic.Dictionary`2.Add(TKey key, TValue value)
            at Ionic.Zip.ZipFile.ReadCentralDirectory(ZipFile zf)
            at Ionic.Zip.ZipFile.ReadIntoInstance(ZipFile zf)
       InnerException: 

May 18, 2012 at 12:53 PM

I have same issue with zip files. Does anybody know how to fix ?