It looks like the help file needs updating - I doubt those operations work on the current versions of Delphi. Also note that ExtractStreamToStream does not work on a zip file, only on zipped data in the format used by AddStreamToStream. It is possible to set up a stream from information given by loading the file into ZipMaster but there seems little point as ExtractFileToStream will do it easier. STORED means just stored with no compression DEFLATED means compressed using the Deflate algorithm (there are other ways to compress but it does not handle them). Assuming that example.zip is deflated data (not a zip file) the following should work but I have not tested it. procedure TForm1.Button1Click(Sender: TObject); var FileData: TMemoryStream; MyData: TMemoryStream; MyOutData: TZipStream; Buf1: Array[1..6] of Byte; begin FileData := TMemoryStream.Create; FileData.Position := 0; FileData.LoadFromFile('c:\Example.zip'); MyData := TMemoryStream.Create; MyData.Position := 0; Buf1[1] := 8; // deflated Buf1[2] := 0; Buf1[3] := 0; Buf1[4] := 0; Buf1[5] := 0; Buf1[6] := 0; MyData.Write(Buf1,6); MyData.Position := 6; MyData.CopyFrom(FileData,FileData.size); MyData.Position := 0; MyOutData := ZipMaster1.ExtractStreamToStream(MyData, 32768); MyOutData.Position := 0; MyOutData.SaveToFile('c:\Extracted.txt'); end; - Russell Peters -----Original Message----- From: delphizip-bounce@xxxxxxxxxxxxx [mailto:delphizip-bounce@xxxxxxxxxxxxx] On Behalf Of Werner Kok Sent: Thursday, 24 February 2005 6:55 PM To: delphizip@xxxxxxxxxxxxx Subject: [delphizip] Re: Method ExtractStreamToStream Hi, Thank you. I was under the impression that "STORED" means that the input stream is compressed and needs to be decompressed. But maybe I misunderstood. I am getting an access violation when I follow the help file statement: Flag := 8; (pFlag( ZipMaster1.ZipStream.Memory ))^ := Flag; Also I do not understand why this must be done on ZipMaster1.ZipStream.Memory, as surely the input stream is the stream that should contain the first 6 bytes and not the output stream? I must be missing something terribly, sorry if I sound stupid. Thanks for the help, Werner -----Original Message----- From: delphizip-bounce@xxxxxxxxxxxxx [mailto:delphizip-bounce@xxxxxxxxxxxxx]On Behalf Of Roger Aelbrecht Sent: 23 February 2005 08:24 PM To: delphizip@xxxxxxxxxxxxx Subject: [delphizip] Re: Method ExtractStreamToStream Werner Kok wrote: > Hi, > > Please look at what I'm doing below and help my frustrated soul, I > will be forever gratefull! > > > procedure TForm1.Button1Click(Sender: TObject); > var FileData: TMemoryStream; > MyData: TMemoryStream; > MyOutData: TZipStream; > Buf1: Array[1..6] of Byte; > > begin > > FileData := TMemoryStream.Create; > FileData.Position := 0; > FileData.LoadFromFile('c:\Example.zip'); > > MyData := TMemoryStream.Create; > MyData.Position := 0; > Buf1[1] := 0; > Buf1[2] := 0; > Buf1[3] := 9; > Buf1[4] := 9; > Buf1[5] := 9; > Buf1[6] := 9; > MyData.Write(Buf1,6); > MyData.Position := 6; > MyData.CopyFrom(FileData,0); > MyData.Position := 0; > > MyOutData := ZipMaster1.ExtractStreamToStream(MyData, 32768); > MyOutData.Position := 0; > MyOutData.SaveToFile('c:\Extracted.txt'); > > end; > > > > Why oh why is the file 'c:\Extracted.txt' still the compressed zip > file? > > > > > Thank you so much!, > > Werner Kok > > As far as I can see in your code the extra bytes you entered are not correct. You have set it as 'stored' so no decompression is done, because the UnzDLL thinks the data in the stream was not compressed. >From the help file : <quote> The first 6 bytes of the input stream are reserved: - The first two bytes are used as a flag, STORED = 0 or DEFLATED = 8. Type pFlag = ^Smallint; pCRC = ^Cardinal; Var Flag: SmallInt; CRC: Cardinal; Flag := 8; (pFlag( ZipMaster1.ZipStream.Memory ))^ := Flag; </quote> So for a compressed file the flag should be set to 8. Then there is the problem of the CRC. the last 4 bytes are the calculated CRC, if you do not have this value you will receive CRC errors, of course you can ignore them. To ignore the CRC errors create an OnCRCError event handler and set the DoExtract parameter to true. HTH -- Roger Aelbrecht http://home.tiscali.be/driehoeksw -- No virus found in this outgoing message. Checked by AVG Anti-Virus. Version: 7.0.300 / Virus Database: 266.4.0 - Release Date: 22/02/2005 ----------- To unsubscribe from this list, send an empty e-mail message to: delphizip-request@xxxxxxxxxxxxx and put the word unsubscribe in the subject. ----------- To unsubscribe from this list, send an empty e-mail message to: delphizip-request@xxxxxxxxxxxxx and put the word unsubscribe in the subject. ----------- To unsubscribe from this list, send an empty e-mail message to: delphizip-request@xxxxxxxxxxxxx and put the word unsubscribe in the subject.