I have declared outputBuffer as a Byte and used it accordingly:
TFile.WriteAllBytes(outputPath, outputBuffer);
When I compile my program, Delphi outputs:
[DCC Error] StormLib.pas(56): E2010 Incompatible types: 'System.TArray[System.Byte] and 'Byte'
Have I used the wrong/out-dated data type for my variable? What must I do to get my program to compile?
Thank you in advanced!
Use TBytes instead. The WriteAllBytes method takes TBytes which is defined as TArray<Byte> and so is an array of bytes, not just a single 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;
You error message clearly shows that incompatible types are not Byte and Byte, but TArray<Byte> and Byte. Frankly - that is what expected. Array of bytes is much more than single byte.
Make variable of TArray<Byte> type and use it to contain the value.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With