0

We are using WinSCP to transfer files to a SFTP server by invoking commands in .net code. On the other end, an automated process grabs the file and moves it to another location. The below is the .Net code being used.

With winscp.StandardInput 
   .WriteLine("option batch abort") 
   .WriteLine("option confirm off") 
   .WriteLine("open sftp://" & username & ":" & password & "@" & remotehost) 
   .WriteLine("option transfer binary") 
   .WriteLine("lcd " & localFilePath) 
   If Not remoteFilePath Is Nothing Then .WriteLine("cd " & remoteFilePath) 
   If remoteFileName Is Nothing Then .WriteLine("put " & localFileName) Else .WriteLine("put " & localFileName & " """ & remoteFileName & """") 
   .Close() 
End With

In some cases, when the WinSCP issues the PUT command,

  1. Creates the partial file
  2. Renames it back to original name
  3. The process at the other end moves the file
  4. Then our process creates the partial file again and tries to delete the file with original name.

Not sure why the step#4 is happening, as we don't have any logic in our code to place the partial file again and delete the original file.

Please see the following log from the SFTP server.

  1. 2015-03-05 22:30:59 - Account\UserID [3346178]created /in/YYYXXX.xml.filepart - 226 - 1178853 - 22
  2. 2015-03-05 22:31:21 - Account\UserID [3346178]rnfr /in/YYYXXX.xml.filepart - 350 - - 22
  3. 2015-03-05 22:31:21 - Account\UserID [3346178]rnto /in/YYYXXX.xml - 250 - - - 22
  4. 2015-03-05 22:31:25 - Account\UserID [3346215]sent /in/YYYXXX.xml - 226 - 17924096 - 22
  5. 2015-03-05 22:31:26 - Account\UserID [3346220]dele /in/YYYXXX.xml - 250 - - - 22
  6. 2015-03-05 22:31:28 - Account\UserID [3346209]created /in/YYYXXX.xml.filepart - 226 - 1178853 - 22
  7. 2015-03-05 22:31:28 - Account\UserID [3346209]dele /in/YYYXXX.xml - 550 - - - 22

From the log the original file(YYYXXX.xml) is already deleted by the other process (refer #5) and gives the below error.

Unable to SFTP XML file. Error Message: from PutSFTP: There was an error transferring YYYXXX.xml. Error deleting file 'YYYXXX.xml'. After resumable file upload the existing destination file must be deleted. If you do not have permissions to delete file destination file, you need to disable resumable file transfers. No such file or directory. Error code: 2 Error message from server (en): File not found Request code: 13

Also there is no pattern in the occurrence of this issue i.e not based on file size, date, etc.

We have already included the option confirm off in the script, so resuming should take place as needed. We are using WinSCP Version 5.0.5 (Build 1782).

Is there anything else we need to change/configure ? Let me know what additional info you need from me.

5
  • Can you include WinSCP log showing the problem? Commented Mar 12, 2015 at 6:53
  • Martin, I have deleted the topic which I posted in ServerFault. We didn't enable WinSCP logging so, I dont have it. Only the error message is available. Commented Mar 12, 2015 at 19:17
  • You cannot reproduce this? Commented Mar 13, 2015 at 7:22
  • No Martin, we are not able to reproduce this error. Commented Mar 13, 2015 at 19:20
  • So please make sure you enable logging, so you have available, once the problem occurs again. Commented Mar 13, 2015 at 19:40

1 Answer 1

2

Have you tried using the .NET assembly that you can get as a separate download? I've been using it for a while and it hasn't given me any problems. WinSCP .NET Library

You may also want to look at this bug report : Here

ResumeSupport requires that the .filepart file be written to the ftp site and deleted or renamed. If you don't have permission, you get an error.

The fix is to turn off resume support by updating the WinSCP.ini file and set ResumeSupport=2

More documentation on Resume support here

Sign up to request clarification or add additional context in comments.

3 Comments

Thanks for your inputs Rick. But we have the permissions already and it is working fine all the time. This issue is just random, occurred 3 rimes in the total of 4 years.
Did you try my suggestion? Does this answer/solve your problem?
Rick, we have the permissions already and it is working fine all the time. This issue is just random, occurred 3 rimes in the total of 4 years

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.