[
  {
    "Id": "231941",
    "ThreadId": "68194",
    "Html": "<p>the code is throwing an error for duplicate files. i tried to catch the exception which will successfully creates the zip, BUT the exception is getting thrown when a file with the same name is added from a separate directory and only one of the files is added.</p>\r\n<p>example only - not real code.</p>\r\n<p>i used zip1.addDirectory(&quot;c:\\dir1&quot;)&nbsp; to add a directory :</p>\r\n<p>c:\\dir1\\dirone\\file.txt</p>\r\n<p>c:\\dir1\\dirtwo\\file.txt</p>\r\n<p>c:\\dir1\\dirthree\\file.txt</p>\r\n<p>&nbsp;</p>\r\n<p>&nbsp;</p>\r\n<p>&nbsp;</p>",
    "PostedDate": "2009-09-07T13:45:35.71-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "231949",
    "ThreadId": "68194",
    "Html": "<p>Can you show me the real code?&nbsp; And also the real exception.</p>\r\n<p>Also which version of the library are you using?</p>\r\n<p>The zipfile specification insists on a unique name for each entry&nbsp;within the zipfile.&nbsp;&nbsp; But normally when you add a directory with AddDirectory(), files with the same name, but from different subbdirectories, get unique entry names in the zipfile.&nbsp; The directory path is considered part of the entry name.</p>\r\n<p>&nbsp;</p>",
    "PostedDate": "2009-09-07T14:06:56.683-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "231970",
    "ThreadId": "68194",
    "Html": "<p>im converting this program to use DotNetZip from DynaZip, and the way things are done is different, but i tried to retain some of it. im not the original author.</p>\r\n<p>i think i found the issue. it was my code. the original author coded a bunch of methods for adding files to and from a list of FILES. it was done this way it seems to be displayed in the tree views, etc. the code i was running was using the file list, then calling addDirectory with the directory path from each file in the list. i just took the time to fix it and the zip is showing all 3 files correctly.</p>\r\n<p>the Exception was an ArgumentException &quot;The entry 'file.txt' already exists in the zip archive.&quot;</p>\r\n<p>the code below is the buggy code.</p>\r\n<p><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Dim MyID As New UserSettings<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Dim zip1 As MyZip<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; If MyMode = RecipientMode.Suppliers Then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; zip1 = New MyZip(MyNode, MyUserID, MyFilePaths, New ThreadSafe(Me, pbZipProgress, pbMinorZipProgress))<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Else<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; zip1 = New MyZip(MyNode, MyUserID, lvRecipients.Items(0).SubItems(0).Text.Trim, lvRecipients.Items(0).SubItems(2).Text.Trim, MyFilePaths, New ThreadSafe(Me, pbZipProgress, pbMinorZipProgress))<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; End If<br><br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Select Case MyFileSelectionType<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Case FileAccess.FileSelectionType.FileList, FileAccess.FileSelectionType.SingleDirectory<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; For Each FilePath As OneFile In MyFileList<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; zip1.addFile(FilePath.PathAndName)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Next<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Case FileAccess.FileSelectionType.ParentDirectory<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; '*** new code that should get all directories<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; For Each f As OneFile In MyFileList<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; zip1.addDirectory(f.DirectoryPath)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Next<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; End Select<br><br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; zip1.save() ' will be threaded so all below will need to be moved<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Exit Sub 'testing only</p>\r\n<p>...</p>\r\n<p>&nbsp;</p>\r\n<p>&nbsp;</p>\r\n<p>the calling methods in MyZip class</p>\r\n<p>&nbsp;</p>\r\n<p>Public Sub addFile(ByVal file As String)<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 'old<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; zip1.AddFile(file)<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 'new<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 'Try<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; '&nbsp;&nbsp;&nbsp; zip1.AddFile(file)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 'Catch ex As ArgumentException<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; '&nbsp;&nbsp;&nbsp; If Not ex.Message.ToLower().Contains(&quot;already exists&quot;) Then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ' throw new error<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; '&nbsp;&nbsp;&nbsp; End If<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 'End Try<br><br>&nbsp;&nbsp;&nbsp; End Sub<br><br>&nbsp;&nbsp;&nbsp; Public Sub addDirectory(ByVal dir As String)<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 'old<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; zip1.AddDirectory(dir)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 'new<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 'Try<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; '&nbsp;&nbsp;&nbsp; zip1.AddDirectory(dir)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 'Catch ex As ArgumentException<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; '&nbsp;&nbsp;&nbsp; If Not ex.Message.ToLower().Contains(&quot;already exists&quot;) Then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ' throw new error<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; '&nbsp;&nbsp;&nbsp; End If<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 'End Try<br><br>&nbsp;&nbsp;&nbsp; End Sub<br>&nbsp;&nbsp;&nbsp; Public Sub save()<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; zip1.Save(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) &amp; &quot;\\SNETPC_Temp\\&quot; &amp; filename)<br>&nbsp;&nbsp;&nbsp; End Sub</p>\r\n<p>&nbsp;</p>\r\n<p>these are the values that were fed into the addDirectory method. the new code only adds &quot;C:\\dir1&quot;</p>\r\n<p>&nbsp;&nbsp;&nbsp;&nbsp; f.DirectoryPath&nbsp;&nbsp; &nbsp;&quot;C:\\dir1\\dirone\\&quot;&nbsp;&nbsp; &nbsp;String</p>\r\n<p>&nbsp;&nbsp;&nbsp;&nbsp; f.DirectoryPath&nbsp;&nbsp; &nbsp;&quot;C:\\dir1\\dirthree\\&quot;&nbsp;&nbsp; &nbsp;String</p>\r\n<p>&lt;exception time&gt;</p>\r\n<p>---</p>\r\n<p>this is my new code using the new property list</p>\r\n<p>Select Case MyFileSelectionType<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Case FileAccess.FileSelectionType.FileList, FileAccess.FileSelectionType.SingleDirectory<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; For Each FilePath As OneFile In MyFileList<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; zip1.addFile(FilePath.PathAndName)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Next<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Case FileAccess.FileSelectionType.ParentDirectory<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; '*** new code that should get all directories<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; For Each path As String In MyDirList<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; zip1.addDirectory(path)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Next<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; End Select</p>\r\n<p>&nbsp;</p>\r\n<p>thanks for your quick response</p>\r\n<p>&nbsp;</p>",
    "PostedDate": "2009-09-07T15:33:32.823-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "231972",
    "ThreadId": "68194",
    "Html": "<p>it seems adding the directories separately causes the same error above.</p>\r\n<p>&quot;C:\\dir1\\dirone\\&quot; and &quot;C:\\dir1\\dirthree\\&quot;</p>\r\n<p>&nbsp;</p>\r\n<p>edit: forgot to add the version # 1.8.4.22</p>\r\n<p>&nbsp;</p>\r\n<p>&nbsp;&nbsp;&nbsp;&nbsp; stack&nbsp;&nbsp; &nbsp;&quot;&nbsp;&nbsp; at Ionic.Zip.ZipFile.InsureUniqueEntry(ZipEntry ze1)<br>&nbsp;&nbsp; at Ionic.Zip.ZipFile.AddFile(String fileName, String directoryPathInArchive)<br>&nbsp;&nbsp; at Ionic.Zip.ZipFile.AddOrUpdateDirectoryImpl(String directoryName, String rootDirectoryPathInArchive, AddOrUpdateAction action, Int32 level)<br>&nbsp;&nbsp; at Ionic.Zip.ZipFile.AddOrUpdateDirectoryImpl(String directoryName, String rootDirectoryPathInArchive, AddOrUpdateAction action)<br>&nbsp;&nbsp; at Ionic.Zip.ZipFile.AddDirectory(String directoryName, String directoryPathInArchive)<br>&nbsp;&nbsp; at Ionic.Zip.ZipFile.AddDirectory(String directoryName)<br>&nbsp;&nbsp; at FileAccess.MyZip.addDirectory(String dir) in C:\\Documents and Settings\\ye456c\\My Documents\\SNETPC\\SNETPC2006\\FileAccess\\MyZip.vb:line 55&quot;&nbsp;&nbsp; &nbsp;String</p>",
    "PostedDate": "2009-09-07T15:40:53.523-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "231992",
    "ThreadId": "68194",
    "Html": "<p>That makes sense.&nbsp;</p>\r\n<p>If you call AddDirectory(dirName), all of the files found in the directory, and its subdirectories, are added to the zipfile, starting at the root.&nbsp; so if you have a directory called c:\\dir1, containing&nbsp;file1.txt, and a subbdirectory called subdir, with a file2.txt, and you call AddDirectory(&quot;c:\\dir1&quot;) , then in the zipfile you will have /file1.txt, and /subdir/file2.txt.&nbsp; If you then have a c:\\dir2 with similar contents, and you call AddDirectory(), you will get an exception.</p>\r\n<p>The wat to avoid the problem is to add each directory into its own directory in the zipfile.&nbsp; call AddDirectory(&quot;c:\\dir1&quot;, &quot;dir1&quot;), and AddDirectory(&quot;c:\\dir2&quot;, &quot;dir2&quot;).&nbsp;</p>\r\n<p>&nbsp;</p>",
    "PostedDate": "2009-09-07T17:15:40.35-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "231999",
    "ThreadId": "68194",
    "Html": "<p>that worked.&nbsp;&nbsp; my solution looks like this. zip1.AddDirectory(dir, dir).</p>\r\n<p>it doesnt seem to complain that i gave it the full path including the C:\\</p>\r\n<p>&nbsp;</p>\r\n<p>Thanks!</p>",
    "PostedDate": "2009-09-07T17:49:26.733-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  }
]