I want to compress files into Zip in-memory (I will store the result on a database instead of creating files in the file system).
How can I read the raw content for the compressed Zip file ?. I can't see any property to read that content, or any method to save that content into an Stream or any other in-memory structure.
function GetZip(UncompressedFile: TStream): TBytes;
var AZipFile: TZipFile;
begin
AZipFile := TZipFile.Create;
try
AZipFile.Add(UncompressedFile);
Result := AZipFile.Data; // ?? How to get the compressed file without saving it to the file system ??
finally
AZipfile.Free;
end;
end;
Thank you.
Thanks to AmigoJack and Remy Lebeau for letting me know that I can use the Zip input Stream to also get the result.
This works fine :