We have a Delphi 2007 program that used SecureBridge 2.6.
When we install SecureBridge 7.0.1 or 7.1.2, and try to compile our program, we get the error:
'There is no overloaded version of 'ReadFile' that can be called with these arguments.'
The offending code looks like this:
h: TScSFTPFileHandle;
buf: array [0..32767] of byte;
count: integer;
pos: int64;
begin
fs := TFileStream.Create(LocalFilename, fmCreate);
try
h := FFTPCli.OpenFile(RemoteFilename, fmOpenExisting);
pos := 0;
count := FFTPCli.ReadFile(h, pos, buf, SizeOf(buf));
It looks like an overload of ReadFile may have been removed in these versions.
I tried changing the call to use the other overload, the one that requires the offset, like this:
count := FFTPCli.ReadFile(h, pos, buf, 0, SizeOf(buf));
But that gets the same error.
Do you have an example of Delphi code that would work with this function now? Or know what I can do to fix the original issue?
Thanks.
Compile error calling ReadFile from Delphi 2007
Re: Compile error calling ReadFile from Delphi 2007
The latest versions of SecureBridge uses the TScSFTPClient.ReadFile method of the following signature:
To obtain the necessary information about using this method, you can use our SFTPClient demo project that can be found in the 'Demos\SFTPClient' folder relatively to the SecureBridge demos installation path.
Code: Select all
function ReadFile(const Handle: TScSFTPFileHandle; FileOffset: Int64; var Buffer: TBytes; Offset, Count: integer): integer; {$ IFNDEF CLR}overload;{$ ENDIF}
Re: Compile error calling ReadFile from Delphi 2007
Thanks - that should help.
I am running into an issue compiling the demo project:
But I am guessing this is an issue in our environment that you cannot address, not sure.
I am running into an issue compiling the demo project:
Code: Select all
Unit ScAlgorithmSupport was compiled with a different version of Zlib.TZStreamRec
Re: Compile error calling ReadFile from Delphi 2007
The latter *was* an issue in our environment.
I was able to figure out what how to get around the original compiler error: our variable 'buf' *must* be declared as a TBytes. Even though TBytes is declared as array of byte, if we declare buf as an array of byte, rather than TBytes, we get the error.
The thing that was really getting me though, is it turned out we had another definition of TByte in a module other than SysUtils. But it was the same, 'array of byte'!
The answer for us is to declare buf as Sysutils.TBytes.
Thanks for your help.
I was able to figure out what how to get around the original compiler error: our variable 'buf' *must* be declared as a TBytes. Even though TBytes is declared as array of byte, if we declare buf as an array of byte, rather than TBytes, we get the error.
The thing that was really getting me though, is it turned out we had another definition of TByte in a module other than SysUtils. But it was the same, 'array of byte'!
The answer for us is to declare buf as Sysutils.TBytes.
Thanks for your help.
Re: Compile error calling ReadFile from Delphi 2007
We are glad to know you have found a solution for the issue.
Feel free to contact us if you have any further questions about our products.
Feel free to contact us if you have any further questions about our products.