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
			
									
									
						ScSFTPClient.OpenFile and WriteFile problems
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);