I recently migrate to Delphi 11.0 this line 'Zip.CopyFrom(Source, 0); generate 'error 'Invalid ZStream operation'
uses system.ZLib;
...
const
ZLIB_GZIP_WINDOWBITS = 31;
ZLIB_DEFLATE_WINDOWBITS = 15;
type
TZLibCompressionLevel = TZCompressionLevel;
procedure ZLibCompressStream(Source, Dest: TStream; const Level: TZLibCompressionLevel;
const GZipFormat: Boolean);
var
WindowBits: Integer;
Zip: TZCompressionStream;
begin
if GZipFormat then
WindowBits := ZLIB_GZIP_WINDOWBITS
else
WindowBits := ZLIB_DEFLATE_WINDOWBITS;
Zip := TZCompressionStream.Create(Dest, Level, WindowBits);
try
Zip.CopyFrom(Source, 0);
finally
FreeAndNil(Zip);
end;
end;
procedure TForm85.Button1Click(Sender: TObject);
var s1,s2:TMemoryStream;
begin
s1:=TMemoryStream.Create;
s1.LoadFromFile('h:\1.txt') ;
s2:=TMemoryStream.Create;
ZLibCompressStream(s1,s2,zcDefault,true);
end;
on Delphi 10 and before no error occurs
It appears to be fixed in 11.1
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With