Hello.
I am using the latest .Net assembly (Btw Thanks for this great product!)
I can get a session connected with SFTP, I can create destination folders, but when I try to PUT files I get an error stating none of the TransferMode's work? I've tried Binary, Ascii and Automatic. Same thing each setting. Using the WinSCP app itself I can use same credentials and keys/fingerprints and get logged in and then I can create Dirs, Read, Write, Delete files. No problem with permissions. This is a prod account and works. We use WinSCP all day long here. I am just trying to automate it.
I just can't figure this out. Any help would be greatly appreciated.
My setup:
Windows 7 enterprise. Visual Studio 2015 all new installs.
Connecting to pretty recent version of OpenBSD SSHd on Windows Server. It is a production server and moves 1000's of files a day so it's probably good to go.
Logs attached.
Code sample: (simplified to read)
Try
' Setup session options
Dim sessionOptions As New SessionOptions
With sessionOptions
.Protocol = Protocol.Sftp
.PortNumber = Trim(txtPort.Text)
.HostName = Trim(txtserverAddr.Text)
.UserName = Trim(TxtLogin.Text)
.SshPrivateKeyPath = Trim(TxtKeyPath.Text)
.SshHostKeyFingerprint = Trim(My.Settings.FingerPrint)
End With
Using session As New Session
session.DebugLogPath = My.Settings.MkInt_RootDir & "\Debug.log"
session.SessionLogPath = My.Settings.MkInt_RootDir & "\Session.Log"
session.Open(sessionOptions)
' Upload files
Dim transferOptions As New TransferOptions
transferOptions.TransferMode = TransferMode.Automatic (Ascii and Binary fail as well)
transferOptions.PreserveTimestamp = False
transferOptions.OverwriteMode = True
Dim transferResult As TransferOperationResult
Dim XFilenames string = "SomeFileName.txt"
Dim DestFilenames As String = "SomeFileName.txt"
Log("Creating Vendor folders on MFTPROD\CLIENT\ area if needed..")
session.DebugLogLevel = 1
session.CreateDirectory("111"))
session.CreateDirectory("111/VendorFolder")
Log("Destination folders Exists - Ok.")
'FAILS HERE. Jumps to 'END USING' statement after about 2 seconds
transferResult = session.PutFiles(XFilenames, DestFilenames, True, transferOptions)
'Throw On any Error
transferResult.Check()
For Each transfer In transferResult.Transfers
rTxtConsole.AppendText("Upload of {0} succeeded" & transfer.FileName)
Next
session.Close()
End Using
Catch ex As Exception
Me.StatusStrip1.Text = "Error Occured.."
Me.StatusStrip1.BackColor = Color.Red
rTxtConsole.AppendText("Error: " & ex.Message & vbCrLf)
End Try
results from my logging window:
Files are ready to deploy...
Beginning Connect Attempt..
Connect Opened, Creating Folders and transferring files..
Creating Vendor folders on MFTPROD\CLIENT\ area if needed..
Creating 111\vendorfolder
Destination folders Created/Exists - Ok.
Moving files C:\MkInterface\rci_sqrname_X*.* to /111/vendorfolder/rci_sqrname_X*.*
Error: Ascii is not supported
I also get "Binary is not supported" and "Automatic is not supported."
Thank you for any help you can provide.