How can i get the Error Message?

Advertisement

Many
Guest

How can i get the Error Message?

I want to get an error message in vb.net, when i as example are not logged or have the wrong password. how can i get that? is that possible?

here is my code.

    ' New ProcessStartInfo created
            Dim p As New ProcessStartInfo

            'Specify the location of the binary
            p.FileName = Application.StartupPath & "\WinSCP.com"

            ' Use these arguments for the process
            p.Arguments = "/command ""option batch on"" ""Option Confirm Off"" ""open " & user & ":" & pw & "@" & adress & """" & remoteDir & " ""Option transfer binary"" ""Get " & remotePattern & " " & localDir & "*"" ""close"" ""exit"""


            'Use a hidden window
            p.WindowStyle = ProcessWindowStyle.Hidden

            ' Start the process
            Dim process1 As Process = Process.Start(p)

            'Dim output As String = process1.StandardOutput.ReadToEnd()

            'warten bis der Process beendet wird.
            process1.WaitForExit()

Reply with quote

Advertisement

Many
Guest

i have found a solution

ok, this is my solution. :lol:
            ' Run hidden WinSCP process
            Dim winscp As Process = New Process()
            winscp.StartInfo.FileName = "winscp.com"
            winscp.StartInfo.Arguments = "/command ""option batch on"" ""Option Confirm Off"" ""open " & user & ":" & pw & "@" & adress & """" & remoteDir & " ""Option transfer binary"" ""Get " & remotePattern & " " & localDir & "*"" ""close"" ""exit"""
            winscp.StartInfo.UseShellExecute = False
            winscp.StartInfo.RedirectStandardInput = True
            winscp.StartInfo.RedirectStandardOutput = True
            winscp.StartInfo.CreateNoWindow = True
            winscp.Start()

            ' Wait until WinSCP finishes
            winscp.WaitForExit()

            'Falls Anmeldungsfehler (z.b. Host nicht gefunden oder Passwort nicht korrekt)
            If winscp.ExitCode <> 0 Then

                ' Collect all output (not used in this example)
                'Hier werden die Erfolgs oder Errormeldungen ausgegeben.
                Dim errorOutput As String = winscp.StandardOutput.ReadToEnd()

                usefulFunctions.logMessage(errorOutput, "ERROR", "downloader.SFTP")
                Return False

            End If

Reply with quote

Advertisement

You can post new topics in this forum