Private Function Compress(data As Byte()) As Byte()
Dim result As Byte() = Nothing
Try
Using memoryStream As New MemoryStream()
Dim method As ZipCompression = ZipCompression.Deflate64
Using zipOutputStream As New ZipOutputStream(memoryStream, method)
Using writer As New StreamWriter(zipOutputStream)
writer.Write(data)
writer.Flush()
result = memoryStream.ToArray()
End Using
End Using
End Using
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
Return result
End Function
Private Function UnCompress(data As Byte()) As Byte()
Dim result As Byte() = Nothing
Try
Using memoryStream As New MemoryStream(data)
Using zipInputStream As New ZipInputStream(memoryStream)
Using reader As New StreamReader(zipInputStream)
result = memoryStream.ToArray
End Using
End Using
End Using
Catch ex As Exception
End Try
Return result
End Function