Function getStrFromStream :String; var t :TStream; s :String; i :Int64; begin t :=TFileStream.Create('c:\1.txt', fmOpenRead); try i :=t.Size; SetLength(s, i); t.ReadBuffer(s[1], i); //ShowMessage(s); result :=s; finally t.Free; end; end; 比较偷懒,论坛里发帖较简单的问题,不如搜索一下快。
memStream.SaveToStream(strStream);
strStream.DataString; //这个就是你要的字符串!
var t :TStream; s :String; i :Int64;
begin
t :=TFileStream.Create('c:\1.txt', fmOpenRead);
try
i :=t.Size;
SetLength(s, i);
t.ReadBuffer(s[1], i);
//ShowMessage(s);
result :=s;
finally
t.Free;
end;
end;
比较偷懒,论坛里发帖较简单的问题,不如搜索一下快。