Hello,
If you are using .Net>1.1 the System.IO.Directory.GetFiles method is able todo a recursive search threw all directorys.
So no more recursive method needed.
You can downoad sorcecode and examples here: http://sharpdevelop.net/OpenSource/SharpZipLib/Download.aspx
A basic example from the link is:
Dim sourceDir As String = txtSourceDir.Text.Trim()
' Simple sanity checks
If sourceDir.Length = 0
MessageBox.Show("Please specify a directory")
Return
Else
If Not Directory.Exists(sourceDir)
MessageBox.Show(sourceDir, "Directory not found")
Return
End If
End If
Dim targetName As String = txtZipFileName.Text.Trim()
If targetName.Length = 0 Then
MessageBox.Show("No name specified", "Zip file name error")
Return
End If
Dim astrFileNames() As String = Directory.GetFiles(sourceDir)
Dim strmZipOutputStream As ZipOutputStream
strmZipOutputStream =
New ZipOutputStream(File.Create(targetName))
REM Compression Level: 0-9
REM 0: no(Compression)
REM 9: maximum compression
strmZipOutputStream.SetLevel(9)
Dim strFile As String
For Each strFile In astrFileNames
Dim strmFile As FileStream = File.OpenRead(strFile)
Dim abyBuffer(strmFile.Length - 1) As Byte
strmFile.Read(abyBuffer, 0, abyBuffer.Length)
Dim objZipEntry As ZipEntry = New ZipEntry(strFile)
objZipEntry.DateTime = DateTime.Now
objZipEntry.Size = strmFile.Length
strmFile.Close()
strmZipOutputStream.PutNextEntry(objZipEntry)
strmZipOutputStream.Write(abyBuffer, 0, abyBuffer.Length)
Next
strmZipOutputStream.Finish()
strmZipOutputStream.Close()
MessageBox.Show("Operation complete")
All the best,
Martin