如何转换TB的二进制文件? (使用的MemoryStream) [英] How to convert TBytes to Binary File? (using MemoryStream)

查看:323
本文介绍了如何转换TB的二进制文件? (使用的MemoryStream)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何转换 TB的键入一个二进制文件使用的MemoryStream

How can i convert Tbytes type to a Binary file using MemoryStream?

推荐答案

如果您有可用TBytesStream Uwe的答案会工作。如果不是:

Uwe's answer will work if you have TBytesStream available. If not:

procedure SaveBytesToFile(const Data: TBytes; const FileName: string);
var
  stream: TMemoryStream;
begin
  stream := TMemoryStream.Create;
  try
    if length(data) > 0 then
      stream.WriteBuffer(data[0], length(data));
    stream.SaveToFile(FileName);
  finally
    stream.Free;
  end;
end;

这篇关于如何转换TB的二进制文件? (使用的MemoryStream)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆