EldoS | Feel safer!

Software components for data protection, secure storage and transfer

SFTP Changing Directory, What's wrong

Also by EldoS: RawDisk
Access locked and protected files in Windows, read and write disks and partitions and more.
#36986
Posted: 06/11/2016 19:59:31
by A A (Standard support level)
Joined: 06/11/2016
Posts: 1

Hi,
I need some help please.

I’m trying to change the directory to /etc/httpd/ but It won’t do it? What wrong with my code?



Code
procedure TfrmMain.ToolButton3Click(Sender: TObject);
var
  DirHandle: ByteArray;
begin


    try
DirHandle:=SFTPClient.OpenDirectory('/etc/httpd/');
edit1.Text := '/etc/httpd/';
    except
      on E : Exception do
      begin
        Log('Unable to change directory: [' + E.Message + ']', true);
        Exit;
      end;
    end;
    try
      SftpClient.CloseHandle(DirHandle);
      FCurrentDir := StrToANSI(SftpClient.RequestAbsolutePath(edit1.Text));
    except
      FCurrentDir := '.';

   // Refresh;
  end;


end;
#36991
Posted: 06/12/2016 13:38:16
by Ken Ivanov (EldoS Corp.)

Thank you for contacting us.

SFTP doesn't have a concept of current directory. You must always use absolute paths when you refer to the files.

You can [carefully] use relative paths too, yet the result will depends on server implementation (in most cases, the path will be relative to user's home page). Use RequestAbsolutePath() method to convert relative paths to absolute ones.

Please see the SFTP samples as to how manage remote directory browsing.

Ken

Reply

Statistics

Topic viewed 674 times

Number of guests: 1, registered members: 0, in total hidden: 0




|

Back to top

As of July 15, 2016 EldoS Corporation will operate as a division of /n software inc. For more information, please read the announcement.

Got it!