ScSFTPClient.OpenFile and WriteFile problems

Discussion of open issues, suggestions and bugs regarding network security and data protection solution - SecureBridge
Post Reply
EAC
Posts: 2
Joined: Fri 17 Sep 2010 06:59
Location: Germany

ScSFTPClient.OpenFile and WriteFile problems

Post by EAC » 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

Dimon
Devart Team
Posts: 2910
Joined: Mon 05 Mar 2007 16:32

Post by Dimon » Mon 20 Sep 2010 10:11

To solve the problem try to use the following code:

Code: Select all

  RemoteHandle:=ScSFTPClient1.OpenFile(ScSFTPClient1.RetrieveAbsolutePath('.')+remotefile,[ScSFTPUtils.FoCreate]);

Code: Select all

  ScSFTPClient1.WriteFile(RemoteHandle, Offset, Buffer[0], Count);

EAC
Posts: 2
Joined: Fri 17 Sep 2010 06:59
Location: Germany

Worx!!!

Post by EAC » Mon 20 Sep 2010 12:38

Hi Dimon, I don't know where's the big difference but it works. Thanks !!! :D

Dimon
Devart Team
Posts: 2910
Joined: Mon 05 Mar 2007 16:32

Post by Dimon » Tue 21 Sep 2010 14:12

Feel free to contact us if you have any further questions about SecureBridge.

Post Reply