0 votes
by (8.4k points)
edited

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)
edited

Hello,

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.Connect(serverName);
        sftp.Login(userName, password);

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

        sftp.Disconnect();

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

by (17.7k points)
edited

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

...