Public Sub Zip(ByVal files() As String, ByVal ZipPath As String)
Dim i As Integer
Dim s As New ZipOutputStream(File.Create(ZipPath))
Dim entry As ZipEntry
s.SetLevel(5)
For i = 0 To files.GetUpperBound(0)
Dim fs As New FileStream(files(i), FileMode.Open)
Dim br As New BinaryReader(fs)
entry = New ZipEntry(files(i))
s.PutNextEntry(entry)
s.Write(br.ReadBytes(fs.Length), 0, fs.Length)
fs.Close()
br.Close()
Next
s.Finish()
s.Close()
End Sub
Public Sub Unzip(ByVal zipFile As String, ByVal UnzipToFolder As String)
Dim nByte As Integer
Dim s As New ZipInputStream(File.OpenRead(zipFile))
Dim entry As ZipEntry
Dim data(2048) As Byte
data(2048) = New Byte()
entry = s.GetNextEntry
Do
Dim fs As New FileStream(Path.Combine(UnzipToFolder, Path.GetFileName(entry.Name)), FileMode.Create)
Dim bw As New BinaryWriter(fs, System.Text.Encoding.ASCII)
nByte = s.Read(data, 0, data.GetLength(0))
While nByte > 0
bw.Write(data, 0, nByte)
nByte = s.Read(data, 0, data.GetLength(0))
End While
fs.Close()
bw.Close()
entry = s.GetNextEntry
Loop While Not (entry Is Nothing)
s.Close()
End Sub
Public Sub Zip(ByVal files() As String, ByVal ZipPath As String)
Dim i As Integer
Dim s As New ZipOutputStream(File.Create(ZipPath))
Dim entry As ZipEntry
Dim filesArray As New ArrayList()
s.SetLevel(5)
'check for wildcard "*" search pattern in files()
For i = 0 To files.GetUpperBound(0)
If Path.GetFileNameWithoutExtension(files(i)).IndexOf("*") >= 0 Then
filesArray.AddRange(Directory.GetFiles(Path.GetDirectoryName(files(i)), Path.GetFileName(files(i))))
Else
filesArray.Add(files(i))
End If
Next
filesArray.TrimToSize()
For i = 0 To filesArray.Count - 1
Dim fs As New FileStream(CType(filesArray(i), String), FileMode.Open)
Dim br As New BinaryReader(fs)
entry = New ZipEntry(CType(filesArray(i), String))
s.PutNextEntry(entry)
s.Write(br.ReadBytes(fs.Length), 0, fs.Length)
fs.Close()
br.Close()
Next
s.Finish()
s.Close()
End Sub