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.