0 votes
by (8.4k points)

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
by (58.9k points)


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'.

by (18.0k points)

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