Error when copying file to sftp using vb.net

Advertisement

Aggyey
Joined:
Posts:
1
Location:
Melbourne

Error when copying file to sftp using vb.net

Hi,
With the same login detail I can login to the server using WINSCP but getting error when doing it through vb.net
I am trying to copy the file to a sftp location but getting error the code I am using is:

*********************************************************************************
Try
' Setup session options
Dim sessionOptions As New SessionOptions
With sessionOptions
.Protocol = Protocol.Sftp
.HostName = remotehost
.UserName = username
.Password = password
.SshHostKeyFingerprint = "ssh-rsa 2048 xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx"
End With
Using session As Session = New Session
' Connect
session.Open(sessionOptions)
' Upload files
Dim transferOptions As New TransferOptions
transferOptions.TransferMode = TransferMode.Automatic
Dim transferResult As TransferOperationResult
transferResult = session.PutFiles(filename, remotefolder, False, transferOptions)
' Throw on any error
transferResult.Check()
If transferResult.IsSuccess Then
errmsg = "Upload succeeded"
Return True
Else
' Print results
Dim transfer As TransferEventArgs
For Each transfer In transferResult.Transfers
errmsg = "ERROR file transfer - sending " & transfer.FileName
Next
End If
End Using
Catch e As Exception
errmsg = "ERROR session - " & e.Message
Return False
End Try
**************************************************************************************************

I am getting error at "transferResult.Check" the error is as follows:

"A first chance exception of type 'WinSCP.SessionRemoteException' occurred in WinSCP.dll
Cannot create remote file '/tCONF_MF_IN/con_mf_80063589_20130816100833.DAT'"

Please help!!!

Reply with quote

Advertisement

JasonRkr
Joined:
Posts:
13
Location:
Sunny Southern California

Aggyey,

I understand you can login to the server manually, but once in can you actually create a file? This sounds like a permissions issue.

Jason

Reply with quote

martin
Site Admin
martin avatar
Joined:
Posts:
41,441
Location:
Prague, Czechia

Re: Error when copying file to sftp using vb.net

Checking (or posting here if you cannot help yourself) a session log (Session.SessionLogPath) file may provide more hints.
Also note that the exception likely has an inner exception associated, with more details.

Reply with quote

Advertisement

You can post new topics in this forum