[
  {
    "Id": "165527",
    "ThreadId": "49468",
    "Html": "For example, how can you exclude &quot;*.pst&quot; files?   I was thinking there would be a zip.addDirectory(source, filestoexclude) kind of thing..\r\n<div id=\"ctl00_ctl00_MasterContent_Content_PostRepeater_ctl22_ReplyContentDiv\" style=\"display:none\"></div>\r\n",
    "PostedDate": "2009-03-06T14:50:12.94-08:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "165528",
    "ThreadId": "49468",
    "Html": "The current method signature is: <br>\r\n<br>\r\nZipFile.AddSelectedFiles(&quot;name != *.pst&quot;, MyDirectory, True) <br>\r\n<br>\r\nTrue  means &quot;recurse directories&quot;. <br>\r\n<br>\r\nDoes it make sense to reverse the Directory and the selection criteria string?   <br>\r\nDoes it make sense to default the recurse directories behavior to &quot;true&quot; ? <br>\r\n",
    "PostedDate": "2009-03-06T14:51:55.947-08:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "165607",
    "ThreadId": "49468",
    "Html": "Hi Cheeso,<br>\r\n<br>\r\nYes it make sense to reverse source and selection, for the recursive bool is less evident.\r\n",
    "PostedDate": "2009-03-06T23:17:13.92-08:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "165840",
    "ThreadId": "49468",
    "Html": "Hey Dom, thanks for the feedback.  I'm looking at that method, and I feel like it could go either way. <br>\r\n<br>\r\nTo keep similarity with the existing AddDirectory() method, the order of params should be AddSelectedFiles(directoryPath, selectionCriteria).<br>\r\nTo keep similarity with the AddSelectedFiles() method, the order of params should be AddSelectedFiles(selectionCriteria, directoryPath).<br>\r\n<br>\r\nTo address this, I may add a new overload for AddDirectory(), and specify <br>\r\nAddDirectory(directoryPath, selectionCriteria).  (with recursion always true). <br>\r\nBut the problem there is, there is already an AddDirectory(String, String) = the second string is the directory path to use in the archive. \r\n",
    "PostedDate": "2009-03-08T12:33:55.143-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "166073",
    "ThreadId": "49468",
    "Html": "Using 1.8.1.15 -<br>\r\nI tried the ZipFile.AddSelectedFiles(&quot;name != *.pst&quot;, SourceDirectory, True) but it did not zip all the files or subdirectories within the SourceDirectory.<br>\r\nIt did not error, just my expectation was that it would zip all files and subdirectories as before, yet exclude any .pst files.<br>\r\nYou mentioned above you might try to add a new overload to AddDirectory. When you do, I'll be happy to test.<br>\r\nQuestion though, when you say selectionCriteria, does that mean to include or exclude? Or both depending on syntax?\r\n",
    "PostedDate": "2009-03-09T07:12:16.677-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "166182",
    "ThreadId": "49468",
    "Html": "On the AddSelectedFiles thing - <br>\r\n<br>\r\nAddSelectedFiles(&quot;name != *.pst&quot;, SourceDir, True) is expected to add all the files in SourceDir or any child directory, that are  not pst files (not ending in .pst as an extension) into the zip file. <br>\r\nYou said it didn't behave as you expected.  What did it do?  Which files or folders were not included, that you thought should be included? <br>\r\n<br>\r\nI found a glitch in the FileSelector, and fixed it, just this morning.  but I'm not sure it's the same problem you are running into here. <br>\r\nThe problem I found was that the match was failing if a filename contained more than one dot.  Like Form1.Designer.vb would not match &quot;*.*&quot;    I've fixed that, I think. <br>\r\nWhat did YOU see? <br>\r\n<br>\r\nI also noticed a problem in the example code in the doc - I had omitted a call to zip.Save after adding the files!!  whoops. <br>\r\n<br>\r\n<br>\r\n",
    "PostedDate": "2009-03-09T11:01:18.327-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "166192",
    "ThreadId": "49468",
    "Html": "I basically took this code in my program:<br>\r\n            zipArchive.AddDirectory(SourceFolder)<br>\r\n            zipArchive.CompressionLevel = Zlib.CompressionLevel.LEVEL9_BEST_COMPRESSION<br>\r\n            zipArchive.UseZip64WhenSaving = Ionic.Zip.Zip64Option.Always<br>\r\n            zipArchive.TempFileFolder = txtFolderSave.Text<br>\r\n            zipArchive.Save(DestFile)<br>\r\n<br>\r\nChange it to:<br>\r\n            zipArchive.AddSelectedFiles(&quot;name != *.pst&quot;, SourceDir, True)<br>\r\n            zipArchive.CompressionLevel = Zlib.CompressionLevel.LEVEL9_BEST_COMPRESSION<br>\r\n            zipArchive.UseZip64WhenSaving = Ionic.Zip.Zip64Option.Always<br>\r\n            zipArchive.TempFileFolder = txtFolderSave.Text<br>\r\n            zipArchive.Save(DestFile)<br>\r\n<br>\r\nIt zipped with out error, but when I opened the zip file there were a lot of files/subdirectories missing. So many I just reverted back to the AddDirectory method (because I was working on other stuff - didn't have time to dig deeper).<br>\r\nExample directory folder structure (assume many more sub dirs with files in each)-<br>\r\nMy Docs<br>\r\nMy Docs\\ABC<br>\r\nMy Docs\\XYZ<br>\r\nMy Docs\\VB2005<br>\r\n<br>\r\nAfter zipping, the one folder in particular I noticed was the VB2005 folder (which contains 8 subdirs under VB2005 (many many more folders and file under those 8)); nothing was there. The VB2005 folder was there, but nothing else - 1 file I think. This might not help you much I know, so I'll try to test more soon. <br>\r\nBut that's what happened. <br>\r\n<br>\r\n",
    "PostedDate": "2009-03-09T11:21:33.597-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "166224",
    "ThreadId": "49468",
    "Html": "Thank you, I will look further.\r\n",
    "PostedDate": "2009-03-09T12:39:03.327-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "166233",
    "ThreadId": "49468",
    "Html": "Jeff, you found a bug. <br>\r\nI just fixed it.   It was a one-line thing.  The code was ignoring the recurseDirectories parameter. <br>\r\nv1.8.1.19 has the correction.  Please try it out. <br>\r\nlet me know.<br>\r\n",
    "PostedDate": "2009-03-09T13:03:59.193-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "168539",
    "ThreadId": "49468",
    "Html": "Sorry for the delay in this test...<br>\r\nIt worked fine and recursed thru the directories.<br>\r\nCouple of questions though when you have a moment.<br>\r\nWhen zipping the My Documents directory, upon opening the zip archive, I noticed it contained the whole path from the root. In this case, Users\\jeffy\\Documents\\. The AddDirectory doesn't do this, I assume because of the nature it which it recurses thru the directory. <br>\r\n<span style=\"font-size:16px\"><br>\r\nUsing AddSelectedFiles(&quot;name != *.pst&quot;, SourceDir, True):<br>\r\nIs there a way to eliminate the preceding path to the directory being zipped?<br>\r\nIs there a way to exclude more than one file? In example (and i'm guessing): AddSelectedFiles(&quot;name != *.pst | name != *.doc&quot;, SourceDir, True)<br>\r\nIf there were no exclusions, could I keep the same method syntax and put in some sort of null for the exclusion parameter?<br>\r\n<br>\r\nI want to build in some sort of selectable exclusions GUI for the user. So I need to code it in such a way, roughly speaking, that it is like:<br>\r\n<br>\r\nDim selection1 as string 'user exclusion selection 1<br>\r\nDim selection2 as string 'user exclusion selection 2<br>\r\nDim exclusion as string=&quot;name != &quot; &amp; selection1<br>\r\ncode..<br>\r\ncode..<br>\r\ncode..<br>\r\nAddSelectedFiles(exclusion, SourceDir, True)<br>\r\n<br>\r\nWhere exclusion could be null, could have 1 string value, 2 values, etc.<br>\r\nThat is real rough code just shooting from the hip (I haven't done anything yet), but you get the idea (I hope).<br>\r\n<br>\r\nYour thoughts?<br>\r\n<br>\r\n<br>\r\n<br>\r\n<br>\r\n<br>\r\n<br>\r\n</span><span style=\"font-size:13px\"><br>\r\n<br>\r\n</span>\r\n",
    "PostedDate": "2009-03-16T07:34:38.527-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "170481",
    "ThreadId": "49468",
    "Html": "<p>Hi Jeff! <br>\r\n<br>\r\nAbout compound selection criteria - <br>\r\nYou would use something like this:   (name != *.pst  AND  name != *.doc) <br>\r\nI tried to document this in the help file. <br>\r\n<a href=\"http://cheeso.members.winisp.net/DotNetZipHelp/html/4469abe7-8fa4-101e-975d-305d2fd0affb.htm\">http://cheeso.members.winisp.net/DotNetZipHelp/html/4469abe7-8fa4-101e-975d-305d2fd0affb.htm</a></p>\r\n<p>About the whole path from the root - <br>\r\nThere is an <a href=\"http://cheeso.members.winisp.net/DotNetZipHelp/html/7d6ee4a0-553f-6401-ddf2-2f6e9196268e.htm\">overload</a> of ZipFile.AddSelectedFiles() that allows you to specify the directory in the archive.  </p>\r\n<p>With the overload, you can, for example, do </p>\r\n<pre>  ZipFile.AddSelectedFiles(&quot;name != *.pst&quot;, &quot;c:\\My Docs\\Local&quot;, &quot;archive&quot;, true) \r\n</pre>\r\n<p>This will add all the files in c:\\my docs\\local into the zip archive, but will use &quot;archive&quot; as the root directory <i>in the archive</i>. You will have to test it out to see what I mean. </p>\r\n<p>One last thing:: thanks for confirming that the changes worked as advertised.  If you have NEW questions, I'd appreciate it if you could open a new thread. It makes it nicer for search and it makes it easier for other people to benefit from the Q&amp;A. <br>\r\nthanks!</p>\r\n",
    "PostedDate": "2009-03-21T22:32:54.557-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "173235",
    "ThreadId": "49468",
    "Html": "Hello, my name's Alessandro.<br>\r\nI'm using DotNetZip 1.8.2.3 but I have some problems with the AddSelectedFiles Method when I try to zip a folder with the necessity of exclusion some files.<br>\r\nFor example, I tried to zip the Mozilla Profile Folder:<br>\r\n<br>\r\nZipFile _zip = new ZipFile();<br>\r\n_zip.AddSelectedFiles(&quot;name != parent.lock and name != places.sqlite-journal&quot;, _profilePath, &quot;Mozilla&quot;, true);<br>\r\n_zip.Save(_nameOfZipFile);<br>\r\n<br>\r\nIt makes the zip file but the files contained in the zip file lose the tree of the original folder.<br>\r\n<br>\r\nI found this problem with the AddFile Method too.<br>\r\n<br>\r\nThis is my code:<br>\r\nstring[] _tempArray = Directory.GetFiles(_profilePath, &quot;*.*&quot;, SearchOption.AllDirectories);<br>\r\nint i = -1;<br>\r\n&nbsp;foreach (string _entryToAdd in _tempArray)<br>\r\n{<br>\r\n&nbsp; &nbsp; i++;<br>\r\n&nbsp;&nbsp;&nbsp; if (!(_entryToAdd.Contains(&quot;parent.lock&quot;)) &amp; !(_entryToAdd.Contains(&quot;places.sqlite-journal&quot;)))<br>\r\n&nbsp;&nbsp;&nbsp; {<br>\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; _zip.AddFile(_entryToAdd,&quot;Mozilla&quot;);<br>\r\n&nbsp;&nbsp;&nbsp; }<br>\r\n<br>\r\n}<br>\r\n_zip.Save(_nameOfZipFile);<br>\r\n<br>\r\nSame problem: lose the tree of original folder :-(<br>\r\nI tried with 1.7 branch too.<br>\r\nCan you help me?<br>\r\nMany thanks!<br>\r\nRegards, <br>\r\nAlessandro.<br>\r\n<br>\r\n",
    "PostedDate": "2009-03-29T10:32:22.2-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "173247",
    "ThreadId": "49468",
    "Html": "The behavior with AddSelectedFiles sure looks like a basic bug. I've opened a workitem. <br>\r\n<br>\r\nThe behavior with AddFile is expected and documented.  With AddFile(), you are specifying the name of a file on disk, and the name of a directory in the archive.  The name of the dir in the archive is always &quot;Mozilla&quot;, which means you &quot;flatten&quot; the directory hierarchy.  Using AddFile(), to reproduce the hierarchy of the directory tree on disk, in the zip archive, you would have to append the dir path to &quot;Mozilla&quot;.  eg something like <br>\r\n<br>\r\n<pre>_zip.AddFile(_nameOfFileToAdd, Path.Combine(&quot;Mozilla&quot;,Path.GetDirectoryName(_nameOfFileToAdd.Replace(_profilePath, &quot;&quot;))));\r\n</pre>\r\nYou can also get the directory tree if you call the AddFiles() method:<br>\r\n<br>\r\n<pre>        Ionic.FileSelector ff = new Ionic.FileSelector(selectionCriteria);\r\n        var filesToAdd = ff.SelectFiles(_directoryToZip, recurseDirectories);\r\n        using (ZipFile _zip = new ZipFile())\r\n        {\r\n            _zip.AddFiles(filesToAdd);\r\n            _zip.Save(_nameOfZipFile);\r\n        }\r\n</pre>\r\nBut, this does not allow you to specify the top-level directory to use in the zip, a la &quot;Mozilla&quot;. \r\n",
    "PostedDate": "2009-03-29T11:50:49.537-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "173248",
    "ThreadId": "49468",
    "Html": "This discussion has been copied to a work item. Click <a href=\"http://dotnetzip.codeplex.com/WorkItem/View.aspx?WorkItemId=7374\">here</a> to go to the work item and continue the discussion.",
    "PostedDate": "2009-03-29T11:51:35.417-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "173261",
    "ThreadId": "49468",
    "Html": "Alessandro, the problem is fixed in v1.8.2.5. \r\n",
    "PostedDate": "2009-03-29T13:15:05.947-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "173264",
    "ThreadId": "49468",
    "Html": "I tried in this moment but now there is another problem with the AddSelectedFiles method: in the zip file there is the complete tree path of the original folder.<br>\r\nIn my case &quot;Users\\Administrator\\AppData\\Roaming\\Mozilla\\&quot;. <br>\r\nIt seems that the <em>string directoryPathInArchve</em> value passed to the method is not working. :-(<br>\r\n",
    "PostedDate": "2009-03-29T13:38:56.75-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "173265",
    "ThreadId": "49468",
    "Html": "Thanks for your work however ;-)<br>\r\nI hope you fix this problem in the future.<br>\r\n",
    "PostedDate": "2009-03-29T13:40:11.647-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "173270",
    "ThreadId": "49468",
    "Html": "Yes, I see.  Thanks for working through this with me. <br>\r\nCan you try v1.8.2.7 ?<br>\r\n<br>\r\n",
    "PostedDate": "2009-03-29T14:28:50.337-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "173272",
    "ThreadId": "49468",
    "Html": "Well done, Cheeso! Now it's working!<br>\r\nMany thanks! <br>\r\n<br>\r\n<br>\r\n",
    "PostedDate": "2009-03-29T14:44:55.32-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "173273",
    "ThreadId": "49468",
    "Html": "The 1.8.2.7 version has been fixed this bug ;-)<br>\r\nCongratulations!<br>\r\n",
    "PostedDate": "2009-03-29T14:48:11.677-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "173281",
    "ThreadId": "49468",
    "Html": "Thanks, Alessandro, for reporting it and working through it with me.  \r\n",
    "PostedDate": "2009-03-29T15:32:52.633-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  }
]