Using ReBex to upload different files to FTP server?

401 Views Asked by At

I think im headed in the right direction, but would like anyones input. I am working on a console app that is supposed to look for files in multiple folders, and then upload any files found to each corresponding folder on the FTP server (which is mirrored to match my local directory). Im new to using Rebex and FTP uploads in general. So far my code looks like this:

            //Connect to SFTP server 
            Sftp ftp = new Sftp();
            ftp.Connect(ftpServerURL);
            ftp.Login(ftpUserName, ftpPassword);

            //Upload local files to SFTP Server
            if (ftp.IsConnected == true)
            {
                ftp.PutFile(sourceFilePath, sftpTargetFolder);
            }

My question is: Will this code read through each folder in my local directory and upload them to the sftpTargetFolder? (sourceFilePath and sftpTargetFolder are currently defined in App.Config). Is this even the best method to do this? How do I go about catching errors during the upload? ANY input is appreciated greatly!!! Thank you.

1

There are 1 best solutions below

0
On

I think I found the solution, it seems to work in testing. Take it if you will.

            //Upload local files to FTP server 

            ftp.Upload(sourceFilePath, "/", Rebex.IO.TraversalMode.Recursive, Rebex.IO.TransferMethod.Copy, Rebex.IO.ActionOnExistingFiles.OverwriteOlder);
            ftp.Disconnect();