Disable transfer resume/transfer to temporary filename

Advertisement

minalc
Joined:
Posts:
3

Disable transfer resume/transfer to temporary filename

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!

Reply with quote

Advertisement

minalc
Joined:
Posts:
3

Re: Disable transfer resume/transfer to temporary filename

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;
}

Reply with quote

tpc
Joined:
Posts:
3

Re: Disable transfer resume/transfer to temporary filename

I came here today looking for the same answer. Were you able to come up with anything?

The server that I am connecting to does not allow file renames or deletes so after the file is uploaded it remains named with a . at the beginning and a .filepart extension.

Reply with quote

tpc
Joined:
Posts:
3

Re: Disable transfer resume/transfer to temporary filename

seems "ResumeSupport is not a session option, it is an global configuration option that cannot be set in NET assembly yet."

https://winscp.net/forum/viewtopic.php?t=11342

As he suggests this worked for me if I set ResumeSupport=2 in the WinSCP.ini in the same folder as WinSCP.exe then disable the default config as shown below.

                using (Session session = new Session())
                {
                    session.DefaultConfiguration = false;

                    // Connect
                    session.Open(sessionOptions);    

Reply with quote

minalc
Joined:
Posts:
3

Re: Disable transfer resume/transfer to temporary filename

tpc wrote:

seems "ResumeSupport is not a session option, it is an global configuration option that cannot be set in NET assembly yet."

https://winscp.net/forum/viewtopic.php?t=11342

As he suggests this worked for me if I set ResumeSupport=2 in the WinSCP.ini in the same folder as WinSCP.exe then disable the default config as shown below.

                using (Session session = new Session())
                {
                    session.DefaultConfiguration = false;

                    // Connect
                    session.Open(sessionOptions);    


Thank you! Disabling the default config helped.

But now I have another issue after upload
WinSCP.SessionRemoteException: Upload of file 'abc.pdf' was successful, but error occurred while setting the permissions and/or timestamp. If the problem persists, turn on 'Ignore permission errors' option. ---> WinSCP.SessionRemoteException: No such file or directory.
Error code: 2
Error message from server (en): File not found
Request code: 9


I changed the IgnorePermErrors=1 in WinSCP.ini...that didn't help.

Thank you once again!

Reply with quote

martin
Site Admin
martin avatar
Joined:
Posts:
27,253
Location:
Prague, Czechia

Re: Disable transfer resume/transfer to temporary filename

minalc wrote:

But now I have another issue after upload
WinSCP.SessionRemoteException: Upload of file 'abc.pdf' was successful, but error occurred while setting the permissions and/or timestamp. If the problem persists, turn on 'Ignore permission errors' option. ---> WinSCP.SessionRemoteException: No such file or directory.
Error code: 2
Error message from server (en): File not found
Request code: 9
Please read FAQ:
https://winscp.net/eng/docs/faq_not_owner
_________________
Martin Prikryl

Reply with quote

Advertisement

You can post new topics in this forum