不兼容的类型 - TArray <System.Byte>&Byte

ple*_*103 2 delphi delphi-xe

我已宣布outputBuffer为a Byte并相应地使用它:

TFile.WriteAllBytes(outputPath,outputBuffer);

当我编译我的程序时,Delphi输出:

[DCC错误] StormLib.pas(56):E2010不兼容的类型:'System.TArray [System.Byte]和'Byte'

我的变量使用了错误/过时的数据类型吗?我该怎么做才能让我的程序编译?

先谢谢你!

TLa*_*ama 7

TBytes改用.该WriteAllBytes方法采用TBytes的定义为TArray<Byte>字节数组,而不仅仅是单个数组Byte.

var
  OutputPath: string;
  OutputBuffer: TBytes;
begin
  // use SetLength to set the length of your OutputBuffer
  // byte array, fill it somehow and then call WriteAllBytes
  TFile.WriteAllBytes(OutputPath, OutputBuffer);
end;
Run Code Online (Sandbox Code Playgroud)