Public Function Zip(ByVal str As String) As Boolean
Dim filenames As String = ruta_principal & str
Dim s As ZipOutputStream = New ZipOutputStream(File.Create(ruta_principal & str.Substring(0, str.LastIndexOf(".")) & ".zip"))
s.SetLevel(5)
Dim fs As FileStream
fs = File.OpenRead(filenames)
Dim buffer() As Byte = BitConverter.GetBytes(fs.Length)
Dim largo As Integer = CInt(fs.Length)
Dim entry As ZipEntry = New ZipEntry(str)
s.PutNextEntry(entry)
While largo > 0
Dim numRead As Int64 = fs.Read(buffer, 0, buffer.Length)
s.Write(buffer, 0, numRead)
largo -= numRead
End While
s.Finish()
s.Close()
fs.Close()
s = Nothing
End Function