Topic "Error when copying file to sftp using vb.net"

Author Message
Aggyey
[View user's profile]

Joined: 2013-08-20
Posts: 1
Location: Melbourne
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!!!
JasonRkr
[View user's profile]

Joined: 2013-07-24
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
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24512
Location: Prague, Czechia
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.
Advertisements

You can post new topics in this forum






Search Site

What is WinSCP?

It is award-winning SFTP client, SCP client, FTPS client and FTP client integrated into one software program for file transfer to FTP server or secure SFTP server. [More]

And it's free!

Donate

About donations

$9   $19   $49   $99

About donations

Recommend

WinSCP Privacy Policy

WinSCP License