Topic "Disable transfer resume/transfer to temporary filename"

Author Message
minalc
[View user's profile]

Joined: 2012-09-10
Posts: 3
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!
Advertisements
minalc
[View user's profile]

Joined: 2012-09-10
Posts: 3
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;
}
tpc
[View user's profile]

Joined: 2012-09-11
Posts: 3
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.
tpc
[View user's profile]

Joined: 2012-09-11
Posts: 3
seems "ResumeSupport is not a session option, it is an global configuration option that cannot be set in NET assembly yet."

http://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.

Code:

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

                    // Connect
                    session.Open(sessionOptions);
minalc
[View user's profile]

Joined: 2012-09-10
Posts: 3
tpc wrote:
seems "ResumeSupport is not a session option, it is an global configuration option that cannot be set in NET assembly yet."

http://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.

Code:

                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!
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24512
Location: Prague, Czechia
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:
http://winscp.net/eng/docs/faq_not_owner
_________________
Martin Prikryl
Advertisements

You can post new topics in this forum






Search Site

What is WinSCP?

It is award-winning SFTP client, SCP client, FTPS client and FTP client integrated into one software program for file transfer to FTP server or secure SFTP server. [More]

And it's free!

Donate

About donations

$9   $19   $49   $99

About donations

Recommend

WinSCP Privacy Policy

WinSCP License