Roger Aelbrecht wrote: > 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 I forgot to mention in my previous post that the statement MyOutData := ZipMaster1.ExtractStreamToStream(MyData, 32768); is also dangerous. If your Mydata stream is larger than 32768 there could be a problem. It is better to use MyOutData := ZipMaster1.ExtractStreamToStream(MyData, MyData.Size); -- 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.