See list of file transfer synchronous methods available in Rebex SFTP:
for multi file operations there are these synchronous methods:
If the upload fails you will get an exception. You can retry the file transfer with the code snippet below:
int cnt = 0;
int maxRetry = 3;
Sftp sftp = new Sftp();
sftp.Connect(server);
sftp.Login(user, password);
while (cnt <= maxRetry)
{
try
{
sftp.PutFile(@"localPathToFile", "remotePathToFile");
sftp.Disconnect();
break;
}
catch (NetworkSessionException ex)
{
if (cnt == maxRetry)
{
sftp.Disconnect();
throw;
}
if (ex.Status != NetworkSessionExceptionStatus.ProtocolError)
{
// reconnect needed if the status is other than ProtocolError
sftp.Disconnect();
sftp = new Sftp();
sftp.Connect(server);
sftp.Login(user, password);
}
cnt++;
}
}
}