[
  {
    "Id": "715843",
    "ThreadId": "283838",
    "Html": "\r\n<p>I've a folder called Development. In that folder I've a lot of Visual Studio solutions. I like to zip my Development folder; however, I don't want to include the\r\n<strong>bin&nbsp;</strong>folders&nbsp;and <strong>obj</strong> folders in the zip file. Is this possible?&nbsp;</p>\r\n",
    "PostedDate": "2011-12-21T19:30:41.097-08:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "716333",
    "ThreadId": "283838",
    "Html": "<p>Sure,</p>\r\n<p>there are a number of ways to do it. One is to create a list of directories within your app and call ZipFile.AddItems(), passing that list.</p>\r\n<p>Another way is to use the FileSelector class within DotNetZip.&nbsp; Call ZipFile.AddSelectedFiles(\"name != .\\bin\\*.* and name != .\\obj\\*.*\") . (There are other options for that method, see the documentation for full details.</p>\r\n<p>&nbsp;</p>",
    "PostedDate": "2011-12-22T14:53:19.753-08:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "716336",
    "ThreadId": "283838",
    "Html": "<p>One way to select a set of files from the filesystem is to use LINQ.&nbsp; For example.</p>\r\n<div style=\"color: black; background-color: white;\">\r\n<pre><span style=\"color: blue;\">using</span> (<span style=\"color: blue;\">var</span> zip = <span style=\"color: blue;\">new</span> ZipFile())\r\n{\r\n    <span style=\"color: green;\">// select all files that are not in the bin or obj dir</span>\r\n    <span style=\"color: blue;\">var</span> fileNames = (<span style=\"color: blue;\">from</span> fn <span style=\"color: blue;\">in</span> Directory.GetFiles(<span style=\"color: #a31515;\">\".\"</span>, <span style=\"color: #a31515;\">\"*.*\"</span>, SearchOption.AllDirectories)\r\n                <span style=\"color: blue;\">where</span> !fn.StartsWith(<span style=\"color: #a31515;\">\".\\bin\\\") &amp;&amp; !fn.StartsWith(\"</span>.\\obj\\\")\r\n                <span style=\"color: blue;\">select</span> fn).ToList();\r\n    zip.AddFiles(fileNames);\r\n    zip.Save(archiveName);\r\n}\r\n\r\n</pre>\r\n</div>",
    "PostedDate": "2011-12-22T14:58:42.387-08:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "716356",
    "ThreadId": "283838",
    "Html": "<p>Thanks for the fast reply. I tried both suggestions, but they are not working. This is my code:</p>\n<p><span style=\"font-size: 10pt;\">using&nbsp;(var&nbsp;zipFile&nbsp;=&nbsp;new&nbsp;ZipFile())</span></p>\n<p><span style=\"font-size: 10pt;\">{&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></p>\n<p><span style=\"font-size: 10pt;\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; zipFile.AddDirectory(Config.FullPathSourceDir);</span></p>\n<p><span style=\"font-size: 10pt;\">&nbsp; &nbsp; &nbsp; &nbsp; zipFile.AddSelectedFiles(@\"name&nbsp;!=&nbsp;.\\bin\\*.*&nbsp;and&nbsp;name&nbsp;!=&nbsp;.\\obj\\*.*\");</span></p>\n<p><span style=\"font-size: 10pt;\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; zipFile.Save(Config.FullPathTargetFile);</span></p>\n<p><span style=\"font-size: 10pt;\">}</span></p>\n<pre>Config.FullPathSourceDir and Config.FullPathTargetFile are strings&nbsp;</pre>\n<pre>with directory and file information.</pre>\n<pre><br /></pre>\n<pre>The content of the bin folder and the obj folder is still copied to the zip file.</pre>",
    "PostedDate": "2011-12-22T15:45:25.27-08:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "718437",
    "ThreadId": "283838",
    "Html": "<p>Your code is not right, for what you want to do.&nbsp; Check the documentation for DotNetZip.</p>\r\n<p>AddDirectory adds all files.&nbsp; Bin and obj will be added if you use that call.</p>\r\n<p>To NOT add all those files, use the AddSelectedFiles() method, with the appropriate overload. Check the documentation to determine which overload you need.</p>\r\n<p>Check the reference documentation to understand what these methods do.</p>",
    "PostedDate": "2011-12-29T13:42:17.12-08:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "721989",
    "ThreadId": "283838",
    "Html": "<p>I tried out the overloads from the documentation and I didn't get any of them to work my way. However, I modified your LINQ code sample a bit (the where clause) and got it working my way now. My working code:</p>\r\n<pre>\t\t\t<span>using</span>&nbsp;(<span>var</span>&nbsp;zipFile&nbsp;=&nbsp;<span>new</span>&nbsp;<span>ZipFile</span>())\r\n\t\t\t{\r\n\t\t\t\t<span>//&nbsp;select&nbsp;all&nbsp;files&nbsp;that&nbsp;are&nbsp;not&nbsp;in&nbsp;the&nbsp;bin&nbsp;or&nbsp;obj&nbsp;dir</span>\r\n\t\t\t\t<span>var</span>&nbsp;fileNames&nbsp;=&nbsp;(<span>from</span>&nbsp;fn&nbsp;<span>in</span>&nbsp;<span>Directory</span>.GetFiles(<span>Config</span>.FullPathSourceDir,&nbsp;<span>\"*.*\"</span>,&nbsp;<span>SearchOption</span>.AllDirectories)\r\n\t\t\t\t\t\t\t\t&nbsp;<span>where</span>&nbsp;!fn.Contains(<span>\"\\\\bin\\\\\"</span>)&nbsp;&amp;&amp;&nbsp;!fn.Contains(<span>\"\\\\obj\\\\\"</span>)\r\n\t\t\t\t\t\t\t\t&nbsp;<span>select</span>&nbsp;fn).ToList();\r\n \r\n\t\t\t\tzipFile.AddFiles(fileNames);\r\n\t\t\t\tzipFile.Save(<span>Config</span>.FullPathTargetFile);\r\n\t\t\t}</pre>",
    "PostedDate": "2012-01-07T17:41:32.52-08:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "723396",
    "ThreadId": "283838",
    "Html": "<p>Glad it's working for you.</p>\n<p>My code should have used \"EndsWith()\" instead of StartsWith(), but now I'm not sure EndsWith is a method on System.String.</p>\n<p>But you have it sorted, so, it's all good.</p>",
    "PostedDate": "2012-01-10T15:03:45.26-08:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  }
]