在 Delphi 10.4 中,我尝试使用以下代码将 a 转换TStream
为 a :string
function MyStreamToString(aStream: TStream): string;
var
SS: TStringStream;
begin
if aStream <> nil then
begin
SS := TStringStream.Create('');
try
SS.CopyFrom(aStream, 0); // Exception: TStream.Seek not implemented
Result := SS.DataString;
finally
SS.Free;
end;
end else
begin
Result := '';
end;
end;
但是在这个代码行中,我得到一个异常“TStream.Seek not implemented”:SS.CopyFrom(aStream, 0);
为什么?我怎样才能“治愈”这段代码?