We were doing some manual process to download from and upload to a remote SFTP server with FileZilla. With the client software we didn't have any permission issues.
Recently we decided to move it to a scheduled function using VB.NET. The downloading worked well (so I removed it from my code just to make the code sample concise).
But for uploading, the program ran into an error:
WinSCP.SessionRemoteException: 'Cannot create remote file '/some path/on/remote/myFile.txt.filepart'.
Permission denied.
Error code: 3
Error message from server (en): Permission denied'
Below is the code for uploading the file.
Using session As New Session
session.Open(sessionOptions)
Dim transferOptions As New TransferOptions
transferOptions.TransferMode = TransferMode.Binary
Dim transferResult As TransferOperationResult
' localFilePath = "C:\somepath\myFile.txt"
If Not String.IsNullOrEmpty(localFilePath) And File.Exists(localFilePath) Then
transferResult = session.PutFiles(localFilePath, "/some path/on/remote/", False, transferOptions)
transferResult.Check() 'error was thrown here
Else
Throw New FileNotFoundException("The file could not be found")
End If
End Using
Any help is appreciated, thank you for your time.