[
  {
    "Id": "186345",
    "ThreadId": "55202",
    "Html": "Hello! My name's Alessandro.<br>\r\nI'm using DotNetZip 1.8.2.11 Beta and I love it. But I'd like to have a method (or a procedure) to exclude a directory from Zip method.<br>\r\n<br>\r\nExample:<br>\r\nI've a directory &quot;Pippo&quot; with three subdirectories (no empty): &quot;FolderOne&quot;, &quot;FolderTwo&quot; and &quot;FolderThree&quot;. I need to Zip the &quot;Pippo&quot; directory but excluding the &quot;FolderOne&quot; directory, for example. For the files, I can use the searchCriteria in AddSelectedFiles method to exclude some files. How can I do this with a directory?<br>\r\n<br>\r\nMany thanks!<br>\r\nRegards,<br>\r\nAlessandro.<br>\r\n",
    "PostedDate": "2009-05-03T16:23:23.177-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "186580",
    "ThreadId": "55202",
    "Html": "Alex, I believe you can do this with a filespec that matches the directory.<br>\r\n<br>\r\nname != Pippo\\FolderOne\\*.* <br>\r\n<br>\r\nWhat have you tried?\r\n",
    "PostedDate": "2009-05-04T08:54:40.4-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "186739",
    "ThreadId": "55202",
    "Html": "I'm using Linux (and Mono 2.2) and this solution does not work (I wrote <em>name != Pippo/FolderOne/*.*</em> ). Tomorrow I will try on Windows too, but I think that in the string searchCriteria is possible specify only the filename without the path (full or partial).<br>\r\n<br>\r\nThank you however.<br>\r\nBye.<br>\r\n",
    "PostedDate": "2009-05-04T17:09:35.94-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "186817",
    "ThreadId": "55202",
    "Html": "Well, I tried on Windows too and it does not work.<br>\r\n<br>\r\nEDIT: I downloaded the source code and in FileSelector.cs (at lines 540~544) I can read:<br>\r\n&quot;///<strong>If the name pattern contains any slashes, it is</strong><br>\r\n&nbsp;///<strong> matched to the entire filename, including the path</strong>; otherwise, it is matched<br>\r\n&nbsp;/// against only the filename without the path.&nbsp;<strong> This means a pattern of &quot;*\\*.*&quot; matches <br>\r\n&nbsp;/// all files one directory level deep</strong>, while a pattern of &quot;*.*&quot; matches all files in <br>\r\n&nbsp;/// all directories.&quot;<br>\r\n<br>\r\n<br>\r\nSo, now I think it is a bug.<br>\r\n<br>\r\nBye.<br>\r\n<br>\r\nEDIT:<br>\r\nI've resolved my issue with this:<br>\r\n<br>\r\n&nbsp;for (int i = 0; i &lt; ProfileToBackup.Count; i++)<br>\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; string[] FolderToBackup = (string[])ProfileToBackup[i];<br>\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; DirectoryInfo ProfileDirectory= new DirectoryInfo(FolderToBackup[1]);<br>\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; FileInfo[] FileList = ProfileDirectory.GetFiles(&quot;*.*&quot;, SearchOption.AllDirectories);<br>\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; foreach (FileInfo CurrentFile in FileList)<br>\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (NameOfProgram == &quot;OperaBrowser&quot; &amp;&amp; Environment.OSVersion.ToString().Contains(&quot;Unix&quot;) &amp;&amp; CurrentFile.DirectoryName.Contains(Environment.GetFolderPath(Environment.SpecialFolder.Personal) + &quot;/.opera/mail&quot;))<br>\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>\r\n<br>\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else Zip.AddFile(CurrentFile.FullName, Path.GetDirectoryName(CurrentFile.FullName.Replace(FolderToBackup[1], FolderToBackup[0]))); &nbsp;<br>\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>\r\n<br>\r\nSo, I can exclude the entire &quot;mail&quot; folder.<br>\r\n",
    "PostedDate": "2009-05-04T23:48:12.723-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "187028",
    "ThreadId": "55202",
    "Html": "This discussion has been copied to a work item. Click <a href=\"http://dotnetzip.codeplex.com/WorkItem/View.aspx?WorkItemId=7733\">here</a> to go to the work item and continue the discussion.",
    "PostedDate": "2009-05-05T11:22:43.343-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "188176",
    "ThreadId": "55202",
    "Html": "<p>Alessandro, I'm glad you solved your problem, but I am still trying to see if I can understand it.</p>\r\n<p>When I use the code below, I get the expected results: excluding a directory from the files that are inserted into the zip.</p>\r\n<pre>\t<span style=\"color:#a020f0\">using</span> (<span style=\"color:#228b22\">ZipFile</span> <span style=\"color:#b8860b\">zip</span> = <span style=\"color:#a020f0\">new</span> ZipFile())\r\n\t{\r\n\t    <span style=\"color:#5f9ea0\">zip</span>.AddSelectedFiles(<span style=\"color:#bc8f8f\">&quot;name != Pippo\\\\two\\\\*.*&quot;</span>, <span style=\"color:#bc8f8f\">&quot;Pippo&quot;</span>, <span style=\"color:#5f9ea0\">true</span>);\r\n\t    <span style=\"color:#5f9ea0\">zip</span>.Save(_zipFileName);\r\n\t}\r\n</pre>\r\n<p>All files in the Pippo directory are included in the zip, except files in the Pippo\\two subdirectory. Is this what you want? It works for me with v1.8.3.1. &nbsp;</p>",
    "PostedDate": "2009-05-08T09:01:24.58-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "188271",
    "ThreadId": "55202",
    "Html": "<p>Yes! Now it works very well! Thank you very much!</p>",
    "PostedDate": "2009-05-08T13:05:04.72-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "270157",
    "ThreadId": "55202",
    "Html": "<p>Hi Cheeso,</p>\r\n<p>&nbsp;&nbsp;&nbsp; I'm using the exclusion feature and its working perfectly except for when I try to exclude a file or folder with spaces. For example,</p>\r\n<p>I'm trying to do this:</p>\r\n<p>&nbsp;</p>\r\n<div style=\"color:Black;background-color:White\">\r\n<pre><span style=\"color:Blue\">using</span> (ZipFile zip = <span style=\"color:Blue\">new</span> ZipFile())\r\n{\r\n    zip.UpdateSelectedFiles(<span style=\"color:#A31515\">&quot;name != C:\\\\folder\\\\File 1&quot;</span>, <span style=\"color:#A31515\">&quot;C:\\\\Folder&quot;</span>, <span style=\"color:#A31515\">&quot;Folder&quot;</span>, <span style=\"color:Blue\">true</span>);\r\n}\r\n</pre>\r\n</div>\r\n<p>&nbsp;</p>\r\n<p>but it seems to be getting confused by the space and throws this exception:</p>\r\n<p>System.ArgumentException: '1'<br>at Ionic.FileSelector._ParseCriterion(String s)<br>at Ionic.FileSelector..ctor(String selectionCriteria)<br>at Ionic.Zip.ZipFile._AddOrUpdateSelectedFiles(String selectionCriteria, String directoryOnDisk, String directoryPathInArchive, Boolean recurseDirectories, Boolean wantUpdate)<br>at Ionic.Zip.ZipFile.UpdateSelectedFiles(String selectionCriteria, String directoryOnDisk, String directoryPathInArchive, Boolean recurseDirectories)</p>\r\n<p>I tried putting quotes around the path like this:<span style=\"color:Blue\">&nbsp;</span></p>\r\n<p><span style=\"color:Blue\">\r\n<div style=\"color:Black;background-color:White\">\r\n<pre><span style=\"color:Blue\">using</span> (ZipFile zip = <span style=\"color:Blue\">new</span> ZipFile())\r\n{\r\n    zip.UpdateSelectedFiles(<span style=\"color:#A31515\">&quot;name != \\&quot;C:\\\\folder\\\\File 1\\&quot;&quot;</span>, <span style=\"color:#A31515\">&quot;C:\\\\Folder&quot;</span>, <span style=\"color:#A31515\">&quot;Folder&quot;</span>, <span style=\"color:Blue\">true</span>);\r\n}\r\n</pre>\r\n</div>\r\n</span></p>\r\n<pre>but it threw the same exception. Any way around this?<br><br>Thanks<br></pre>",
    "PostedDate": "2009-12-22T22:35:56.247-08:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  }
]