Dart Home | PowerTCP Zip Compression for Active | Custom Development | Reply | PowerTCP Zip Compression for ActiveX Topics | Forums |
Author | Forum: PowerTCP Zip Compression for ActiveX Topic: How to I Decompress/Compress without creating a ZIP file? |
Dwight From: Bromley, United Kingdom Posts: 3 Member Since: 11/04/04 |
posted November 4, 2004 11:02 AM Hi I have a byte array that contains a zip file that I'm trying to unzip and display. I have written the following piece of code in VB6 but it does not seem to work. Dim Stream1 As New DartStream Dim Stream2 As New DartStream Dim lsByte() as Byte ' laByte is populated with the ZIP stream. Zip1.FileStore.Clear Stream1.Write laByte Zip1.FileStore.Load Stream1 Zip1.FileStore(1).Extract Stream2 Stream2.Position = 0 MsgBox Stream2.ReadString When I run the above piece of code the program crashes on "Stream1.Write laByte" with "The file is not identifies as a compliant zip file" Does anyone have any idea of how I can do this in VB6. TIA Dwight |
Tony Priest![]() From: Utica, NY USA Posts: 8466 Member Since: 04/11/00 |
posted November 5, 2004 9:06 AM It's impossible for me to advise you based on this code example. I don't know how you created laByte so I don't know if it's a valid zip file. Would it be possible to write a small demo app that shows what you are trying to report. That we could run it here, click a button and see the exact same thing you do. If so, please zip the app up and send it to support@dart.com |
Dwight From: Bromley, United Kingdom Posts: 3 Member Since: 11/04/04 |
posted November 8, 2004 7:07 AM Hi I basically have an XML file where one of the data nodes has data which is compressed into a ZIP file. For the data to be sent to me over the internet the supplier has encoded the data into Base64. I've managed to extract the data and encoded it into a byte array. The byte array is now meant to be the compressed ZIP format and I'm trying to decompress the data so that I now have the data. I've developed the following simple program but I have "The file is not identified as a compliant zip file" error message on the LOAD method. The code is as follows: Sub ZipTest Dim loDomDoc As New DOMDocument Dim loNode As IXMLDOMNode Dim loBase64 As New CryptoLib.Base64 Dim lsBase64 As String Dim laByte() As Byte Dim zippedStream As New DartStream Dim unzippedStream As New DartStream loDomDoc.async = False loDomDoc.validateOnParse = True loDomDoc.Load ("c:\test\schedule3.xml") Set loNode = loDomDoc.selectSingleNode("//Compressed") lsBase64 = loNode.Text lsBase64 = Replace(lsBase64, vbCr, "") lsBase64 = Replace(lsBase64, vbLf, "") laByte = StrConv(loBase64.Decode(lsBase64), vbUnicode) ' Decode from Base64 string into a Byte array. zippedStream.Write laByte ' Store the binary zip file to the DartStream 'Unzip to an Uncompressed DartStream Zip1.FileStore.Clear Zip1.FileStore.Load zippedStream Zip1.FileStore(1).Extract unzippedStream unzippedStream.Position = 0 Debug.Print Len(unzippedStream.ReadString) End Sub |
Tony Priest![]() From: Utica, NY USA Posts: 8466 Member Since: 04/11/00 |
posted November 8, 2004 9:17 AM After this line: zippedStream.Write laByte Please add: zippedStream.Filemode = createAlways zippedStream.Filename = "c:\labyte.zip" Then comment out the rest. Now try to open labyte.zip with a zip program and tell me if it worked. |
Dwight From: Bromley, United Kingdom Posts: 3 Member Since: 11/04/04 |
posted November 8, 2004 9:24 AM Hi I've tried the attach and tried to open the file with PKZIP, but the program reports a "labyte.ZIP - error in ZIP use PKZipFix". Any thoughts? TIA |
Tony Priest![]() From: Utica, NY USA Posts: 8466 Member Since: 04/11/00 |
posted November 8, 2004 9:39 AM Possibilities: 1) loNode.Text is not actually a zip file like you think 2) Any of the following lines may be corrupting the data: lsBase64 = Replace(lsBase64, vbCr, "") lsBase64 = Replace(lsBase64, vbLf, "") laByte = StrConv(loBase64.Decode(lsBase64), vbUnicode) ' Decode from Base64 string into a Byte array. |
Reply | PowerTCP Zip Compression for ActiveX Topics | Forums |
This site is powered by
![]() |