Question:
Hi,
I'm using the simple in-memory ZIP sample that you provide,and create a simple zip file following the right steps. The resulting ZIP file seems to be invalid.
Here is my sample (.NET Framework 4, 64 bits)
Private Sub Button1_Click(sender As System.Object, 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)
' 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()
' 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.
Dim fs As System.IO.FileStream
fs = New System.IO.FileStream("out.zip", System.IO.FileMode.Create)
fs.Write(compressedBytes, 0, compressedBytes.Length)
fs.Close()
End
End Sub
The Copy method does NOT return the bytes representing the entire Zip archive. It's a method on the ZipEntry object (not the Chilkat.Zip object), and that alone should give a hint. The Copy method returns the compressed bytes for that particular entry as it would exist within the Zip archive. In other words, it's just the compressed bytes of the entry (not the Zip file format with local file headers, central directory headers, etc.).
To get an in-memory image of the zip archive, call Chilkat.Zip.WriteToMemory
Thank you very much. It worked!