Topic "How can i get the Error Message?"

Author Message
Many

Guest


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.

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()
Many

Guest


ok, this is my solution. Laughing
Code:

            ' 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
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