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

martin

Re: Error uploading files to Remote Directory

Well, startup path is /opt/ftpguests/rcmprod, so I assume you should upload the files to /opt/ftpguests/rcmprod/, not /rcmprod/. The /rcmprod/ does not exist and cannot be created (I assume you do not have permissions to create directories is a root).
rajeshlhegde

Error uploading files to Remote Directory

Hi,
I am trying files to remote directory. The source folder is "Data" (relative to current directory) and the destination is \rcmprod\.

I have attached the log for the session.

here is the code iam using:

// Setup session options
SessionOptions sessionOptions = new SessionOptions
{
Protocol = Convert.ToBoolean(ConfigurationManager.AppSettings["UseSFTP"]) ? Protocol.Sftp : Protocol.Ftp, //If SFTP is configured then use that or else use FTP ; in PROD it should be SFTP
HostName = ConfigurationManager.AppSettings["SFTPHost"],
UserName = ConfigurationManager.AppSettings["SFTPUserName"],
Password = ConfigurationManager.AppSettings["SFTPPassword"],
SshHostKeyFingerprint = Convert.ToBoolean(ConfigurationManager.AppSettings["UseSFTP"]) ? ConfigurationManager.AppSettings["SFTPHostKey"] : null
};

using (Session session = new Session())
{

session.SessionLogPath = GetSessionLogPath();
// Connect
session.Open(sessionOptions);

// Upload files
TransferOptions transferOptions = new TransferOptions();
transferOptions.TransferMode = TransferMode.Binary;

TransferOperationResult transferResult;
transferResult = session.PutFiles(ConfigurationManager.AppSettings["SFTPSourceFolder"], ConfigurationManager.AppSettings["SFTPRemoteFolder"], false, transferOptions);
//rcmtest is the remote folder at the root level

// Throw on any error
transferResult.Check();

// Print results and Archive data file
foreach (TransferEventArgs transfer in transferResult.Transfers)
{

NLog.LogManager.GetCurrentClassLogger().Trace("Upload of {0} succeeded", transfer.FileName);

ArchiveData(transfer.FileName);

}


}