ScSFTPClient.OpenFile and WriteFile problems
Posted: Fri  17 Sep 2010 07:19
				
				Hi, I'm a SFTP and SecureBridge newbee and having problems with following code after succesfull SSHClient and SFTPClient connection:
try
repeat
ScSFTPClient1.ReadDirectory(RemoteHandle);
until ScSFTPclient1.EOF;
finally
ScSFTPClient1.CloseHandle(RemoteHandle);
end;
ProgressBar1.Visible:=True;
LocalHandle:=FileOpen(LocalFile,fmOpenRead);
//up to here everything is ok
RemoteHandle:=ScSFTPClient1.OpenFile
(ScSFTPClient1.RetrieveAbsolutePath('.')+remotefile,[FoCreate]);
try
SetLength(Buffer, ScSFTPClient1.WriteBlockSize);
Offset := 0;
repeat
Count:=FileRead(LocalHandle,Buffer,ScSFTPClient1.WriteBlockSize);
if Count > 0 then
ScSFTPClient1.WriteFile(RemoteHandle, Offset, Buffer, 0, Count);
Offset := Offset + Count;
until Offset>=ProgressBar1.Max; //max = local filesize
result:=True;
finally
FileClose(LocalHandle);
ScSFTPClient1.CloseHandle(RemoteHandle);
end;
When compiling this I get the following errors:
[Pascal Error] Main.pas(172): E2250 There is no overloaded version of 'OpenFile' that can be called with these arguments
[Pascal Error] Main.pas(179): E2250 There is no overloaded version of 'WriteFile' that can be called with these arguments
The SFTPClient demo compiles and works fine (at least the open function, write function is not used) in my environment.
I'm using BDS2006, SecureBridge 2.6.... and CrushFTP server.
Thanks for your help in advance
Heinz
			try
repeat
ScSFTPClient1.ReadDirectory(RemoteHandle);
until ScSFTPclient1.EOF;
finally
ScSFTPClient1.CloseHandle(RemoteHandle);
end;
ProgressBar1.Visible:=True;
LocalHandle:=FileOpen(LocalFile,fmOpenRead);
//up to here everything is ok
RemoteHandle:=ScSFTPClient1.OpenFile
(ScSFTPClient1.RetrieveAbsolutePath('.')+remotefile,[FoCreate]);
try
SetLength(Buffer, ScSFTPClient1.WriteBlockSize);
Offset := 0;
repeat
Count:=FileRead(LocalHandle,Buffer,ScSFTPClient1.WriteBlockSize);
if Count > 0 then
ScSFTPClient1.WriteFile(RemoteHandle, Offset, Buffer, 0, Count);
Offset := Offset + Count;
until Offset>=ProgressBar1.Max; //max = local filesize
result:=True;
finally
FileClose(LocalHandle);
ScSFTPClient1.CloseHandle(RemoteHandle);
end;
When compiling this I get the following errors:
[Pascal Error] Main.pas(172): E2250 There is no overloaded version of 'OpenFile' that can be called with these arguments
[Pascal Error] Main.pas(179): E2250 There is no overloaded version of 'WriteFile' that can be called with these arguments
The SFTPClient demo compiles and works fine (at least the open function, write function is not used) in my environment.
I'm using BDS2006, SecureBridge 2.6.... and CrushFTP server.
Thanks for your help in advance
Heinz
