gbb
New Member
Posts: 2
|
Post by gbb on Oct 2, 2005 10:47:15 GMT -5
'myfiles.zip' contains a number of zipped files. I've extracted one of them (called 'file1.txt') and put the contents in a TStringList called MCLista. I've modified it and want to save the modified contents back to myfiles.zip using ZipFromStream. As you can see from my feeble attempt below, I don't know how to get 'file1.txt' back into 'myfiles.zip'. Help, please.
MStrm := TMemoryStream.Create; MCLista.SaveToStream(MStrm); Zip1.Password := '123abc'; Zip1.ZipName := ProgDir +'\data\MC_htdat1.zip'; Zip1.ZipFromStream( MStrm, Zip1.ZipName ); MStrm.Position := 0; MStrm.Free;
|
|
|
Post by Kevin on Oct 2, 2005 19:39:15 GMT -5
OK, I'm working from memory here but I think what you need to do is this...
MStrm := TMemoryStream.Create; MCLista.SaveToStream(MStrm); MStrm.Position := 0; Zip1.Password := '123abc'; Zip1.ZipName := ProgDir +'\data\MC_htdat1.zip'; FileName := 'WhateverTheOriginalFilenameWas'; Zip1.ZipFromStream( MStrm, FileName ); MStrm.Position := 0; MStrm.Free;
The second parameter of ZipFromStream is the internal filename, that is the name of the file you originally unzipped out of the zip file. If you stored the pathname with the original file, include that too. But don't include the drive name, just something like 'somedir\myfile.txt'.
Kevin
|
|
gbb
New Member
Posts: 2
|
Post by gbb on Oct 3, 2005 6:15:42 GMT -5
The second parameter of ZipFromStream is the internal filename,...
That's it! I had overlooked the 'internal' part. Thanks, Kevin.
|
|