[
  {
    "Id": "593588",
    "ThreadId": "252971",
    "Html": "\r\n<p>I'm trying to get the ZipError event to fire when I have an error adding an entry.&nbsp; I created my list of files I wan and then use the AddFiles method.&nbsp; When I step through the code it enters the AddProgressHandler and exits the sub and I recieve\r\n an exception with &quot;An item with the same key has already been added&quot;.&nbsp; I'm opening an existing zip file and found that occasionally I might have an item in the zip that I'm trying to add again.&nbsp; I would like to be able to use the ZipError event to\r\n capture that information and handle it.</p>\r\n<p>&nbsp;&nbsp;&nbsp; Sub Main</p>\r\n<p>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 'Add the handlers<br>\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; AddHandler objZip.AddProgress, AddressOf AddProgressHandler<br>\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; AddHandler objZip.ZipError, AddressOf ZipErrorHandler</p>\r\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; objZip.CompressionLevel = Ionic.Zlib.CompressionLevel.Default<br>\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; objZip.AddFiles(strSelectedFiles, &quot;&quot;)<br>\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; objZip.Save()</p>\r\n<p>&nbsp;&nbsp;&nbsp; End Sub</p>\r\n<p>&nbsp;&nbsp;&nbsp; Private Sub AddProgressHandler(ByVal sender As Object, ByVal e As AddProgressEventArgs)<br>\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Select Case e.EventType<br>\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Case ZipProgressEventType.Adding_Started<br>\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Console.WriteLine(&quot;Adding files to the zip...&quot;)<br>\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Exit Select<br>\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Case ZipProgressEventType.Adding_AfterAddEntry<br>\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Console.WriteLine(String.Format(&quot;Adding file {0}&quot;, e.CurrentEntry.FileName))<br>\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Exit Select<br>\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Case ZipProgressEventType.Adding_Completed<br>\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Console.WriteLine(&quot;Added all files&quot;)<br>\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Exit Select<br>\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; End Select<br>\r\n&nbsp;&nbsp;&nbsp; End Sub</p>\r\n<p>&nbsp;&nbsp;&nbsp; Private Sub ZipErrorHandler(ByVal sender As Object, ByVal e As ZipErrorEventArgs)<br>\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ' At this point, the application could prompt the user for an action to take.<br>\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ' But in this case, this application will simply automatically skip the file, in case of error.<br>\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Console.WriteLine(&quot;Zip Error,&nbsp; entry {0}&quot;, e.CurrentEntry.FileName)<br>\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Console.WriteLine(&quot;&nbsp;&nbsp; Exception: {0}&quot;, e.Exception)<br>\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ' set the desired ZipErrorAction on the CurrentEntry to communicate that to DotNetZip<br>\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; e.CurrentEntry.ZipErrorAction = ZipErrorAction.Skip<br>\r\n&nbsp;&nbsp;&nbsp; End Sub</p>\r\n",
    "PostedDate": "2011-04-07T08:41:45.617-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "593599",
    "ThreadId": "252971",
    "Html": "<p>Here is the exception detail.</p>\n<p>System.ArgumentException was unhandled<br />&nbsp; Message=\"An item with the same key has already been added.\"<br />&nbsp; Source=\"mscorlib\"<br />&nbsp; StackTrace:<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at System.Collections.Generic.Dictionary`2.Add(TKey key, TValue value)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at Ionic.Zip.ZipFile.InternalAddEntry(String name, ZipEntry entry)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at Ionic.Zip.ZipFile._InternalAddEntry(ZipEntry ze)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at Ionic.Zip.ZipFile.AddFile(String fileName, String directoryPathInArchive)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at Ionic.Zip.ZipFile.AddFiles(IEnumerable`1 fileNames, Boolean preserveDirHierarchy, String directoryPathInArchive)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at Ionic.Zip.ZipFile.AddFiles(IEnumerable`1 fileNames, String directoryPathInArchive)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at Directory_Maintenance.Module1.Main()<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at System.Threading.ThreadHelper.ThreadStart_Context(Object state)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at System.Threading.ThreadHelper.ThreadStart()<br />&nbsp; InnerException:</p>",
    "PostedDate": "2011-04-07T08:58:32.39-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  }
]