minalc wrote:
How can I disable "transfer resume/transfer to temporary filename" preference in my C# .net code?
I am connecting to a SFTP site. I am able to upload a file to the SFTP site, but since I do not have any write permissions, the .filepart name does not get changed to the original file name which is a .pdf file.
Through the command line the file gets uploaded and renamed to the .pdf extension, but the same thing through the C# .Net code, it fails.
Please advise.
Thanks!
By write permissions, I meant WinSCP will not be able to change the filename from .pdf.filepart to .pdf.
Setting the RawSettings "ResumeSupport" = "2" also does not seem to help
Please see the code snippet below:
// Setup session options
SessionOptions sessionOptions = new SessionOptions();
sessionOptions.Protocol = Protocol.Sftp;
sessionOptions.HostName = "SecureFTP.xxx.com";
sessionOptions.UserName = "Username";
sessionOptions.Password = "password";
sessionOptions.SshHostKey = "ssh-rsa 2048 xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx";
sessionOptions.Timeout = new TimeSpan(0, 3, 0);
sessionOptions.AddRawSettings("ResumeSupport", "2");
using (Session session = new Session())
{
// Connect
session.Open(sessionOptions);
// Upload files
TransferOptions transferOptions = new TransferOptions();
transferOptions.TransferMode = TransferMode.Binary;
System.Timers.Timer filetimer = new System.Timers.Timer(30000);
TransferOperationResult transferResult = session.PutFiles(@"\\server\folderOnServer\NeedToUploadFiles\abc.pdf", "/PDFs/", false, transferOptions);
// Check and Throw if any error
transferResult.Check();
return 0;
}
catch (Exception e)
{
Console.WriteLine("Error: {0}", e);
return 1;
}