[
  {
    "Id": "285422",
    "ThreadId": "83047",
    "Html": "<p>Hello.&nbsp; I'm having an issue with the ZipFile.AddSelectedFiles function.&nbsp;&nbsp;&nbsp; If the files I'm zipping contain a &quot;~&quot; and the directoryOnDisk I provide does not match the exact case of the path, I will get the full path in the zip archive, even when I specify an empty string for directoryPathInArchive.&nbsp; Let me give an example.</p>\r\n<p>Let's say I have the following file &quot;5.txt&quot; in my folder &quot;C:\\\\Test&quot;.&nbsp; I want to zip this to somewhere on my harddrive.&nbsp; I do the following.</p>\r\n<h5>ZipFile z = new ZipFile();</h5>\r\n<h5>z.AddSelectedFiles(&quot;name != *.zip*&quot;, &quot;C:\\\\Test\\\\&quot;, &quot;&quot;, true);</h5>\r\n<h5>z.Save(&quot;C:\\\\Data\\\\zipfile.zip&quot;);</h5>\r\n<p>Works as expected.&nbsp; My zip archive contains &quot;5.txt&quot; and nothing else.</p>\r\n<h5>z.AddSelectedFiles(&quot;name != *.zip*&quot;, &quot;C:\\\\test\\\\&quot;, &quot;&quot;, true);</h5>\r\n<p>Also works even though &quot;test&quot; was not cased correctly to match the actual directory.&nbsp; Now I rename &quot;5.txt&quot; to &quot;~5.txt&quot; and repeat the above line.</p>\r\n<p>The result is a zipfile containing Test\\~.5.txt.&nbsp; The full path is present.&nbsp; Now if I correctly type the directory such as:</p>\r\n<h5>z.AddSelectedFiles(&quot;name != *.zip*&quot;, &quot;C:\\\\Test\\\\&quot;, &quot;&quot;, true);</h5>\r\n<p>It works for &quot;~&quot; files.&nbsp; I took a look at the source code and I may have found the issue.&nbsp; On line 558 of ZipFile.Selector is the following:</p>\r\n<h5>string dirInArchive = Path.GetDirectoryName(f).Replace(directoryOnDisk, directoryPathInArchive);</h5>\r\n<p>It looks through each file and does a replace.&nbsp; Path.GetDirectoryName however doesn't seem to return the correct path if the file contains a &quot;~' and the case does not match the directory path.&nbsp; Perhaps this may fix it?</p>\r\n<h5>string dirInArchive = Path.GetDirectoryName(f).ToLower().Replace(directoryOnDisk, directoryPathInArchive);</h5>\r\n<p>I'm not sure if this makes any sense at all but any input would be helpful.&nbsp; I can send a sample project if necessary.</p>",
    "PostedDate": "2010-02-03T11:09:16.573-08:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "285425",
    "ThreadId": "83047",
    "Html": "<p>Sorry my fix suggestion is wrong haha.&nbsp; This instead.</p>\r\n<h5>string dirInArchive = Path.GetDirectoryName(f).ToLower().Replace(directoryOnDisk.ToLower(), directoryPathInArchive);</h5>\r\n<p>Although the .ToLower() for directoryOnDisk could be done before the loop.</p>",
    "PostedDate": "2010-02-03T11:18:32.357-08:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "285474",
    "ThreadId": "83047",
    "Html": "This discussion has been copied to a work item. Click <a href=\"http://dotnetzip.codeplex.com/WorkItem/View.aspx?WorkItemId=10153\">here</a> to go to the work item and continue the discussion.",
    "PostedDate": "2010-02-03T13:09:55.447-08:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "288575",
    "ThreadId": "83047",
    "Html": "<p>Arbel, thanks for the analysis and the bug report. Very helpful .</p>\r\n<p>I've put the fix in; it will be available in v1.9.1.4, or v1.9.5.2.&nbsp;</p>",
    "PostedDate": "2010-02-10T20:53:23.243-08:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "289957",
    "ThreadId": "83047",
    "Html": "<p>v1.9.1.4 is now available.&nbsp; It includes this fix.</p>\r\n<p>&nbsp;</p>",
    "PostedDate": "2010-02-11T20:21:07.907-08:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "290135",
    "ThreadId": "83047",
    "Html": "<p>Thanks!</p>",
    "PostedDate": "2010-02-12T07:39:43.877-08:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  }
]