[
  {
    "Id": "551972",
    "ThreadId": "242425",
    "Html": "\r\n<p>I am wanting to recursively zip up a folder but exclude one file and one folder. &nbsp;I am using VB 2010. &nbsp;My folder structure is as follows:</p>\r\n<p><strong>C:\\Folder\\Folder2\\Folder3\\Folder4 - #</strong></p>\r\n<p>I am zipping up Folder3 (options.Folder) recursively. &nbsp;The folder that contains my program (path) is excluded from the zip. &nbsp;There is one file withing Folder3 that I want to skip as well (somefile.MDB). &nbsp;</p>\r\n<p>&nbsp;</p>\r\n<p>Here is what I have so far:</p>\r\n<p>&nbsp;</p>\r\n<p>Dim options As WorkerOptions = CType(e.Argument, WorkerOptions)</p>\r\n<p>Dim path As String&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;</p>\r\n<p>Dim iWork As Integer&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;</p>\r\n<p>path = System.IO.Path.GetDirectoryName( _&nbsp;&nbsp; &nbsp; &nbsp;System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase)&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;</p>\r\n<p>iWork = Len(path)&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;</p>\r\n<p>'count the number of characters&nbsp;then subtract the # of characters from the end to the =&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;</p>\r\n<p>iWork = iWork - InStrRev(Trim(path), &quot;\\&quot;)&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;</p>\r\n<p>path = Microsoft.VisualBasic.Right(Trim(path), iWork)&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;</p>\r\n<p>Try&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</p>\r\n<p><span style=\"white-space:pre\"></span>Using zip1 As ZipFile = New ZipFile&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</p>\r\n<p><span style=\"white-space:pre\"></span>zip1.AddSelectedFiles(&quot;name != &quot; &amp; options.Folder &amp; &quot;\\&quot; &amp; path &amp; &quot;\\*.*&quot;, options.Folder, CustomerFolder, True)&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</p>\r\n<p><span style=\"white-space:pre\"></span>Me._entriesToZip = zip1.EntryFileNames.Count&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</p>\r\n<p><span style=\"white-space:pre\"></span>Me.SetProgressBars()&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</p>\r\n<p><span style=\"white-space:pre\"></span>AddHandler zip1.SaveProgress, New EventHandler(Of SaveProgressEventArgs)(AddressOf Me.zip1_SaveProgress)&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</p>\r\n<p><span style=\"white-space:pre\"></span>zip1.Save(lblBackupToFolder.Text &amp; &quot;\\&quot; &amp; options.ZipName)&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</p>\r\n<p><span style=\"white-space:pre\"></span>zip1.Dispose()&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</p>\r\n<p><span style=\"white-space:pre\"></span>End Using</p>\r\n<p>End Try</p>\r\n<p>&nbsp;</p>\r\n<p>As you can see, I used the code from Win Forms - ZipUp to get me most of the way. &nbsp;Any help would be greatly appreciated!</p>\r\n",
    "PostedDate": "2011-01-19T08:06:33.15-08:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  }
]