Posted: 2010-06-18 17:16
I am trying to use SFTP to transfer a file from within VB.NET. I've set up a session and can connect to the server when using the Commander interface. Here's my code in VB.NET
' Run hidden WinSCP process
Dim winscp As Process = New Process()
winscp.StartInfo.FileName = gstrFTPProcessLocation 'Location of WinSCP.com (usually C:\Program Files\WinSCP\winscp.com)
winscp.StartInfo.Arguments = "/log=" + LogName
winscp.StartInfo.UseShellExecute = False
winscp.StartInfo.RedirectStandardInput = True
'winscp.StartInfo.RedirectStandardOutput = True
winscp.StartInfo.CreateNoWindow = True
' Feed in the scripting commands
winscp.StandardInput.WriteLine("option batch abort")
winscp.StandardInput.WriteLine("option confirm off")
winscp.StandardInput.WriteLine("open " & gstrFTPSession) 'This is a session you must setup in WinSCP
winscp.StandardInput.WriteLine("put " & strOutFile)
' Collect all output (not used in this example)
'Dim output As String = winscp.StandardOutput.ReadToEnd()
' Wait until WinSCP finishes
I get an exit code of 1 and do not get a log file. This code had been working, but I'm connecting to a new FTP site and it's bombing. If I comment out CreateNoWindow, I see the error message is "Host does not exist".
When I use the console (winscp.com) directly from a command line, I get "Host does not exist" as well. I can connect to other stored sessions just fine thru the console. Just this one site it isn't happy with. And when I use commander, it connects to my stored session just fine.
Any help greatly appreciated.
Location: Prague, Czechia
Are you able to get log if you run WinSCP manually and type the open command in console?
You can post new topics in this forum
And it's free!