Absolute/relative paths and Rename

0 votes
asked Sep 18 by nkov (150 points)

Hi,
Are Rename method parameters (fromPath and toPath) absolute paths?

For instance, will the following code work correctly?

var _ftp = new Sftp();

// Connect and login

_ftp.ChangeDirectory("/home/tmp");

_ftp.PutFile("test.txt", "test.txt");
_ftp.Rename("/home/tmp/test.txt", "/home/uat/test.txt");
Applies to: Rebex SFTP

1 Answer

0 votes
answered Sep 18 by Lukas Matyska (47,190 points)
selected Sep 18 by nkov
 
Best answer

All paths given to methods of the Rebex.Net.Sftp object can be of both kinds absolute or relative.

Path starting with slash '/' is taken as absolute path.
Path not starting with slash '/' is taken as relative path.

commented Sep 18 by nkov (150 points)
Just to be sure.
If the SFTP user has the current directory as "/home/user" and I try to upload the file using PutFile ("test.txt", "tmp/test.txt"), the result file name will be "/home/user/tmp/test.txt ", otherwise, if I try to upload the file using PutFile ("test.txt","/tmp/test.txt "), the result file name will be"/tmp/test .text ". Is it right?
commented Sep 18 by Lukas Matyska (47,190 points)
Yes, exactly.
commented Sep 18 by nkov (150 points)
Thanks a lot.
...