This project is read-only.

DotNetZip 1.9 Exclude Multiple Files/Folders

Jan 19, 2011 at 4:06 PM

I am wanting to recursively zip up a folder but exclude one file and one folder.  I am using VB 2010.  My folder structure is as follows:

C:\Folder\Folder2\Folder3\Folder4 - #

I am zipping up Folder3 (options.Folder) recursively.  The folder that contains my program (path) is excluded from the zip.  There is one file withing Folder3 that I want to skip as well (somefile.MDB).  


Here is what I have so far:


Dim options As WorkerOptions = CType(e.Argument, WorkerOptions)

Dim path As String        

Dim iWork As Integer        

path = System.IO.Path.GetDirectoryName( _      System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase)        

iWork = Len(path)        

'count the number of characters then subtract the # of characters from the end to the =        

iWork = iWork - InStrRev(Trim(path), "\")        

path = Microsoft.VisualBasic.Right(Trim(path), iWork)        


Using zip1 As ZipFile = New ZipFile                

zip1.AddSelectedFiles("name != " & options.Folder & "\" & path & "\*.*", options.Folder, CustomerFolder, True)                

Me._entriesToZip = zip1.EntryFileNames.Count                


AddHandler zip1.SaveProgress, New EventHandler(Of SaveProgressEventArgs)(AddressOf Me.zip1_SaveProgress)                

zip1.Save(lblBackupToFolder.Text & "\" & options.ZipName)                


End Using

End Try


As you can see, I used the code from Win Forms - ZipUp to get me most of the way.  Any help would be greatly appreciated!