no output with VB2010

Advertisement

PitWi
Joined:
Posts:
2
Location:
Vienna

no output with VB2010

My code in VB 2010:

        Dim proc As Process = New Process
        Dim prot As String = ""
        proc.StartInfo.FileName = prg  ' refers to WinSCP programfile
        proc.StartInfo.Arguments = "/console /command /log=C:\Users\pw\Desktop\log.txt"
        proc.StartInfo.UseShellExecute = False
        proc.StartInfo.RedirectStandardInput = True
        proc.StartInfo.RedirectStandardOutput = True
        proc.StartInfo.RedirectStandardError = True
        proc.StartInfo.CreateNoWindow = True
        Try
            proc.Start()
        Catch ex As Exception
            proc.Close()
            proc.Dispose()
            Beep()
            MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
            Exit Sub
        End Try
        proc.StandardInput.WriteLine("option batch abort")
        proc.StandardInput.WriteLine("option confirm off")
        proc.StandardInput.WriteLine("open uid:pwd@mama.uni.ac.at")
        proc.StandardInput.WriteLine("ls")
        proc.StandardInput.Close()
        prot = proc.StandardOutput.ReadToEnd()
        proc.WaitForExit()
        If proc.ExitCode <> 0 Then
            proc.Close()
            proc.Dispose()
            Beep()
            MessageBox.Show("Error", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
            Exit Sub
        End If
        proc.Close()
        proc.Dispose()
        MsgBox(prot)

What I want is a list of the files and directories on the server. I tried several variationes but "prot" is always empty and log.txt isn't created. Why? A similar app with upload of files works great.

Reply with quote

Advertisement

PitWi
Joined:
Posts:
2
Location:
Vienna

Re: no output with VB2010

martin wrote:

Please use WinSCP .NET assembly:
https://winscp.net/eng/docs/library

Thanks.
I did it before and it works but I'm not sure if that's the answer I wanted because WinSCP .NET is really nice but it complicates the setup of my application.

Reply with quote

Advertisement

You can post new topics in this forum