Move files to Sftp server

0 votes
asked Sep 24, 2012 by Rebex KB (8,430 points)
edited Nov 15, 2012

How can I move files from the local machine to a SFTP server? I need the original files to be deleted as part of the move operation.

Applies to: Rebex SFTP

1 Answer

+1 vote
answered Sep 24, 2012 by Tomas Knopp (58,890 points)
edited Nov 15, 2012


It is easy to move files since the release 2012 R1. Use the Upload method in combination with TransferMethod.Move mode to achieve the move funcionality like this:

        string serverName = "server";
        string userName = "username";
        string password = "password";

        Sftp sftp = new Sftp();
        sftp.Login(userName, password);

        // moves the directory data to the SFTP server 'remotePath'
        sftp.Upload(@"C:\data", "/remotePath", 0, TransferMethod.Move, 0 );


This will copy the directory 'data' to SFTP server and delete the local directory 'data'.

commented Nov 15, 2012 by Jan Sotola (17,670 points)
edited Nov 15, 2012

NOTE: if you want to move files from one folder on remote server to another folder on the same server, please see this article.