ZipToString

    <Extension()> _
    Public Function UnZip(compressedText As String) As String
        Dim gzBuffer As Byte() = Convert.FromBase64String(compressedText)
        Using ms As New MemoryStream()
            Dim msgLength As Integer = BitConverter.ToInt32(gzBuffer, 0)
            ms.Write(gzBuffer, 4, gzBuffer.Length - 4)

            Dim buffer As Byte() = New Byte(msgLength - 1) {}

            ms.Position = 0
            Using zipStream As New System.IO.Compression.GZipStream(ms, System.IO.Compression.CompressionMode.Decompress)
                zipStream.Read(buffer, 0, buffer.Length)
            End Using

            Return System.Text.Encoding.Unicode.GetString(buffer, 0, buffer.Length)
        End Using
    End Function
Example:
Dim str As String =  Base64Compressed.UnZip

Description

Descompactação de string

Details

Double click on the code to select all.

 

;