Dim zipedFile As String = filenam
Using fs As io.FileStream = io.File.OpenRead(fileToZip)
Dim buffer As Byte() = New Byte(fs.Length - 1) {}
fs.Read(buffer, 0, buffer.Length)
fs.Close()
Using ZipFile As io.FileStream = io.File.Create(zipedFile)
Using ZipStream As ICSharpCode.SharpZipLib.zip.ZipOutputStream = New ICSharpCode.SharpZipLib.zip.ZipOutputStream(ZipFile)
Dim fileName As String = fileToZip.SubString(fileToZip.LastIndexOf("\") + 1)
Dim ZipEntry = New ICSharpCode.SharpZipLib.zip.ZipEntry(fileName)
ZipStream.PutNextEntry(ZipEntry)
ZipStream.SetLevel(7)
ZipStream.Write(buffer, 0, buffer.Length)
ZipStream.Finish()
ZipStream.Close()
End Using
End Using
End Using