programm freezes when calling ScsftpClient.initialize

Discussion of open issues, suggestions and bugs regarding network security and data protection solution - SecureBridge
Post Reply
RNO
Posts: 1
Joined: Mon 07 Jan 2013 13:55

programm freezes when calling ScsftpClient.initialize

Post by RNO » Mon 21 Jan 2013 14:14

Hello,

I am trying to find out how to connect to the sftp server.
I can connect the ScSSHClient, but when I call the ScSFTPClient.initialize the programm freezes. Any suggestions what to do?

Thanks,
Rob Nowee
See Code Below

Code: Select all

procedure TForm1.Button1Click(Sender: TObject);
var
  OldCursor: TCursor;
  Handle: TScSFTPFileHandle;
  i: Integer;
  Path, Selectedname: String;
  ScFileStorage1: TScFileStorage;
  ScSFTPClient1: TScSFTPClient;
  ScSSHClient1: TScSSHClient;
  Key: TScKey;

begin
  ScFileStorage1:= TScFileStorage.Create(self);
  ScSFTPClient1:= TScSFTPClient.Create(self);
  ScSSHClient1:= TScSSHClient.Create(self);
  ScFileStorage1.Path :='d:\indir';
  ScSSHClient1.KeyStorage := ScFileStorage1;
  ScSSHClient1.HostName := 'sftp.edi-p.staples.eu';
  ScSSHClient1.User := username;
  ScSSHClient1.Password := Password;
  ScSSHClient1.Port := 22;
  ScSFTPClient1.SSHClient := ScSSHClient1;
  if not (FileExists('d:\indir\Key1.key')) then
  begin
    Key := TScKey.Create(ScFileStorage1.Keys);
    Key.KeyName := 'key1';
    Key.ImportFrom('d:\indir\sftp.edi-p.staples.eu.key');
  end;
  ScSSHClient1.HostKeyName := 'Key1';
  ScSSHClient1.Connect;
  ScSFTPClient1.Timeout:=300;
  ScSFTPClient1.Initialize;
  ScSFTPClient1.DownloadFile('*.*','D:\Indir\',True);
  OldCursor := Screen.Cursor;
  try
    Screen.Cursor := crHourGlass;
    Path := '/';
    Path := Trim(Path);
    Handle := ScSFTPClient1.OpenDirectory(Path);
    try
      FileView.Items.Clear;
      repeat
        ScSFTPClient1.ReadDirectory(Handle);
      until ScSFTPClient1.EOF;
    finally
      ScSFTPClient1.CloseHandle(Handle);
    end;

    lbRootDir.Text := ScSFTPClient1.RetrieveAbsolutePath(Path);

    if SelectedName <> '' then begin
      for i := 0 to FileView.Items.Count - 1 do
        if LowerCase(FileView.Items[i].Text) = LowerCase(SelectedName) then begin
          FileView.Selected := FileView.Items[i];
          Exit;
        end;
    end;
  finally
    Screen.Cursor := OldCursor;
  end;
end;

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

Re: programm freezes when calling ScsftpClient.initialize

Post by Dimon » Mon 04 Feb 2013 16:07

I can not reproduce the problem.
Please, try to download the latest SecureBridge build (5.5.1) and check if this problem still exists.

Post Reply