Unable to connect/synchronize using SFTP
Hello,
We are able to connect using the WinSCP client using the same login credentials etc as used in the code below, but we get no errors reported nor does the file get uploaded when running the code. We are successfully using the same code to connect to a different server with no problems. Any help is much appreciated.
Thank you
We are able to connect using the WinSCP client using the same login credentials etc as used in the code below, but we get no errors reported nor does the file get uploaded when running the code. We are successfully using the same code to connect to a different server with no problems. Any help is much appreciated.
Try
' Set up session options
Dim sessionOptions2 As New SessionOptions
With sessionOptions2
.Protocol = Protocol.sftp
.HostName = "xxx.zzz.com"
.UserName = "user"
.Password = "password"
.SshHostKeyFingerprint = "ssh-ed25519 256 xxxxxxxxxxxxxxxxxxx="
End With
sessionOptions2.AddRawSettings("FSProtocol", "2")
Using session2 As New Session
' Connect
session2.Open(sessionOptions2)
' Upload files
Dim transferOptions2 As New TransferOptions
transferOptions2.TransferMode = WinSCP.TransferMode.Binary
Dim sDate2 As String = DateTime.Now.AddDays(1).ToString("yyyyMMdd", System.Globalization.CultureInfo.GetCultureInfo("en-US"))
Dim transferResult2 As TransferOperationResult
transferResult2 = session2.PutFiles("e:\inetpub\wwwroot\iLabs\Imports\" & sDate2 & "_pi_funds.csv", "incoming/", False, transferOptions2)
' Throw on any error
transferResult2.Check()
' Print results
For Each transfer In transferResult2.Transfers
Response.Write(transfer.ToString())
Next
End Using
Catch er As Exception
Console.WriteLine("Error: {0}", er)
End TryThank you