Delphi 中将TMemoryStream转换为'String'
2022-12-26 12:42:31 作者:admin
本文整理自网络,侵删。
function StreamToString(aStream: TStream): string;var SS: TStringStream;begin if aStream <> nil then begin SS := TStringStream.Create(''); try SS.CopyFrom(aStream, 0); // No need to position at 0 nor provide size Result := SS.DataString; finally SS.Free; end; end else begin Result := ''; end;end;
function StreamToString(const Stream: TStream; const Encoding: TEncoding): string;var StringBytes: TBytes;begin Stream.Position := 0; SetLength(StringBytes, Stream.Size); Stream.ReadBuffer(StringBytes, Stream.Size); Result := Encoding.GetString(StringBytes);end;它仅在Delphi XE7中经过测试。
相关阅读 >>
Delphi tfile
Delphi写的播放器核心代码,播放mp3无压力
Delphi 数字签名添加器源码
Delphi tidhttp获取软件版本信息
Delphi 下载网页
Delphi unidbtreegrid判断点击折叠事件
Delphi 校验手机号及身份证号
Delphi中string与pansichar转换
Delphi getmimetypefromfile 获取文件mime类型
Delphi使用迅雷的开放下载引擎下载
更多相关阅读请进入《Delphi》频道 >>
猜你喜欢
联络方式:
400-123-789
邮箱:xiachao@163.com
Q Q:12345678
微信公众号
微信二维码