Post a reply

Options
Add an Attachment

If you do not want to add an Attachment to your Post, please leave the Fields blank.

(maximum 10 MB; please compress large files; only common media, archive, text and programming file formats are allowed)

Options

Topic review

medicstuder

Move files after upload on local server

I am working on a C# console program. So far it is working great. What it does is log into the remote SFTP server and copy files from our server to theirs. What I want it to do after the files are copied is move the local files from the current directory to a "sent" directory.

Here is what I have (it does not throw an errors and when testing the log shows the mv sourcepath to backuppath, but the files still remain in the sourcepath and never appear in the backup path.

transferResult = session.PutFiles(OutboundPath, UploadPath, false, transferOptions);
transferResult.Check();
foreach (TransferEventArgs transfer in transferResult.Transfers)
{
Console.WriteLine("Upload of {0} succeeded", transfer.FileName);
session.MoveFile(transfer.FileName, backuppath);
}