Post a reply

Options
Add an Attachment

If you do not want to add an Attachment to your Post, please leave the Fields blank.

(maximum 10 MB; please compress large files; only common media, archive, text and programming file formats are allowed)

Options

Topic review

PitWi

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.
PitWi

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.