Thank you!
Thank you very much! You solved the problem :D
Greetings,
icekuhn
Greetings,
icekuhn
[color=green]Imports System
Imports WinSCP
Public Class Form1
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
Dim i As Integer
i = Upload()
If i = 0 Then
Label1.Text &= " Erfolg"
Else
Label1.Text &= " Fehlschlag"
End If
End Sub
Public Function Upload() As Integer
Try
' Setup session options
Dim mySessionOptions As New SessionOptions
With mySessionOptions
.Protocol = Protocol.Sftp
.HostName = "10.7.96.123"
.UserName = "XXX_XXX"
.Password = "YYY_YYY"
' .GiveUpSecurityAndAcceptAnySshHostKey = True
' .GiveUpSecurityAndAcceptAnySshHostKey = True
.SshHostKeyFingerprint = "ssh-rsa 1024 62:d8:XX:28:ed:cf:9a:65:eb:ba:8d:2f:4b:ad:a5:63"
.SshPrivateKeyPath = "C:\daten\WinSCPPortable\new\XXX_XXX.ppk"
' .FtpMode = FtpMode.Active
End With
Using mySession As Session = New Session
mySession.SessionLogPath = "C:\daten\VB\File_Uploader_2\File Uploader 2\bin\Debug\test.log"
' Connect
mySession.Open(mySessionOptions)
' Upload files
Dim myTransferOptions As New TransferOptions
myTransferOptions.TransferMode = TransferMode.Binary
Dim transferResult As TransferOperationResult
transferResult = mySession.PutFiles("c:\test\Hund\test.txt", "/upload/", False, myTransferOptions)
' Throw on any error
transferResult.Check()
' Print results
For Each transfer In transferResult.Transfers
Label3.Text &= " Upload of" & transfer.FileName & " succeeded"
Next
End Using
Return 0
Catch e As Exception
Label3.Text &= " " & e.ToString
Return 1
End Try
End Function
End Class[/color]