Chilkat HOME ASP Visual Basic VB.NET C# Visual C++ C MFC Delphi FoxPro Java Perl PHP Python Ruby SQL Server VBScript
|
Zip / Unzip In-Memory
Demonstrates how to do in-memory Zip compression and decompression. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim zip As New Chilkat.Zip()
zip.UnlockComponent("30-day trial")
' Get some byte to compress.
Dim inBytes As Byte()
inBytes = System.Text.Encoding.ASCII.GetBytes(TextBox1.Text)
' Display the length of the uncompressed bytes.
TextBox2.Text = Str(inBytes.Length)
' Append the data to the in-memory Zip object.
' No files are every produced by this example program.
Dim entry As Chilkat.ZipEntry
entry = zip.AppendData("inBytes.dat", inBytes)
' Get the compressed data.
Dim compressedBytes As Byte()
compressedBytes = entry.Copy()
' Show the length of the compressed data.
TextBox3.Text = Str(compressedBytes.Length)
' In a real app, the compressed data might be persisted or sent
' as part of a message over a connection, perhaps as part of a Web Service RPC.
' Now restore the original data from the compressed....
' Create a new Zip object.
Dim zip2 As New Chilkat.Zip()
zip2.NewZip("something.zip")
' Append the compressed data to the in-memory Zip object, and inflate it.
Dim outBytes As Byte()
Dim entry2 As Chilkat.ZipEntry
entry2 = zip2.AppendCompressed("blahblah.dat", compressedBytes)
outBytes = entry2.Inflate()
' Convert the byte array to a string.
Dim c As Char()
c = System.Text.Encoding.Default.GetChars(outBytes)
Dim sb As New System.Text.StringBuilder()
TextBox4.Text = sb.Insert(0, c).ToString()
End Sub
Important: The download for this
example does not contain the ChilkatDotNet.dll which |
Need a specific example? Send a request to support@chilkatsoft.com
© 2000-2007 Chilkat Software, Inc. All Rights Reserved.