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,
- Creates the partial file
- Renames it back to original name
- The process at the other end moves the file
- 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.
- 2015-03-05 22:30:59 - Account\UserID [3346178]created /in/YYYXXX.xml.filepart - 226 - 1178853 - 22
- 2015-03-05 22:31:21 - Account\UserID [3346178]rnfr /in/YYYXXX.xml.filepart - 350 - - 22
- 2015-03-05 22:31:21 - Account\UserID [3346178]rnto /in/YYYXXX.xml - 250 - - - 22
- 2015-03-05 22:31:25 - Account\UserID [3346215]sent /in/YYYXXX.xml - 226 - 17924096 - 22
- 2015-03-05 22:31:26 - Account\UserID [3346220]dele /in/YYYXXX.xml - 250 - - - 22
- 2015-03-05 22:31:28 - Account\UserID [3346209]created /in/YYYXXX.xml.filepart - 226 - 1178853 - 22
- 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.