I've put your sample code out on my webserver but kept getting a permissions error on the log files. After digging into this, I've discovered the following:
I have my code as:
session.DebugLogPath = "c:\inetpub\slashapps\writeoffs\sftp\debug.log"
session.SessionLogPath = "c:\inetpub\slashapps\writeoffs\sftp\session.log"
session.XmlLogPath = "c:\inetpub\slashapps\writeoffs\sftp\xml.log"
session.Open(sessionOptions)
' code fails right after this open command
The writeoffs\sftp folder is setup so that the network service this is running under has permission to make changes. When the code runs, the debug.log file is created. So far, so good. But I get an error when the xml log file is created:
Timeout waiting for WinSCP to respond - Log file c:\inetpub\slashapps\writeoffs\sftp\xml.log was not created in time, please make sure WinSCP has write permissions to the folder
I've set a much longer timeout interval and it still fails. I'd like to just skip the xml log but when I set it to null, it still tries to create it. If I leave out the xmllogpath, it tries to create the xml log file in the c:\windows\temp folder and fails just like it does anywhere else. The other log file works fine so I know the permissions are correct. Any ideas on why the xml one fails? Any way I can force it to not create itself or even ignore the error?
Here is the bottom part of the debug.log:
[2013-05-21 14:25:43.508Z] [0007] Starting "C:\inetpub\slashApps\bin\winscp.exe"
/xmllog="c:\inetpub\slashapps\writeoffs\sftp\xml.log" /xmlgroups /nointeractiveinput /dotnet=515
/ini=nul /log="c:\inetpub\slashapps\writeoffs\sftp\session.log" /console /consoleinstance=_968_83
[2013-05-21 14:25:43.508Z] [0007] Started process 1676
[2013-05-21 14:25:43.508Z] [0012] ExeSessionProcess.ProcessEvents entering
[2013-05-21 14:25:43.523Z] [0007] ExeSessionProcess.InitializeChild leaving
[2013-05-21 14:25:43.523Z] [0007] ExeSessionProcess.Start leaving
[2013-05-21 14:25:43.523Z] [0007] Command: [option batch on]
[2013-05-21 14:25:43.523Z] [0007] ExeSessionProcess.ExecuteCommand entering
[2013-05-21 14:25:43.523Z] [0007] ExeSessionProcess.ExecuteCommand leaving
[2013-05-21 14:25:43.523Z] [0007] Command: [option confirm off]
[2013-05-21 14:25:43.523Z] [0007] ExeSessionProcess.ExecuteCommand entering
[2013-05-21 14:25:43.523Z] [0007] ExeSessionProcess.ExecuteCommand leaving
[2013-05-21 14:25:43.523Z] [0007] Session.SessionOptionsToOpenArguments entering
[2013-05-21 14:25:43.523Z] [0007] Session.SessionOptionsToOpenSwitches entering
[2013-05-21 14:25:43.523Z] [0007] Session.SessionOptionsToOpenSwitches leaving
[2013-05-21 14:25:43.523Z] [0007] Session.SessionOptionsToOpenArguments leaving
[2013-05-21 14:25:43.523Z] [0007] Command: [open -hostkey="ssh-rsa key" -timeout=15 "sftp://username:password@website"]
[2013-05-21 14:25:43.523Z] [0007] ExeSessionProcess.ExecuteCommand entering
[2013-05-21 14:25:43.523Z] [0007] ExeSessionProcess.ExecuteCommand leaving
[2013-05-21 14:26:43.525Z] [0007] Exception: System.TimeoutException: Timeout waiting for WinSCP to respond - Log file c:\inetpub\slashapps\writeoffs\sftp\xml.log was not created in time, please make sure WinSCP has write permissions to the folder
at WinSCP.Session.CheckForTimeout(String additional)
at WinSCP.Session.Open(SessionOptions sessionOptions)
[2013-05-21 14:26:43.525Z] [0007] Session.Cleanup entering
[2013-05-21 14:26:43.525Z] [0007] Terminating process
[2013-05-21 14:26:43.525Z] [0007] Command: [exit]
[2013-05-21 14:26:43.525Z] [0007] ExeSessionProcess.ExecuteCommand entering
[2013-05-21 14:26:43.525Z] [0007] ExeSessionProcess.ExecuteCommand leaving
[2013-05-21 14:26:43.525Z] [0007] ExeSessionProcess.Close entering
[2013-05-21 14:26:43.525Z] [0007] Waiting for process to exit
[2013-05-21 14:26:44.525Z] [0007] Killing process
[2013-05-21 14:26:44.525Z] [0007] ExeSessionProcess.Close leaving
[2013-05-21 14:26:44.525Z] [0007] ExeSessionProcess.Dispose entering
[2013-05-21 14:26:44.556Z] [0012] Aborted
[2013-05-21 14:26:44.556Z] [0012] ExeSessionProcess.ProcessEvents leaving
[2013-05-21 14:26:44.556Z] [0007] ExeSessionProcess.Dispose leaving
[2013-05-21 14:26:44.556Z] [0007] Disposing log readers
[2013-05-21 14:26:44.556Z] [0007] Session.Cleanup leaving
[2013-05-21 14:26:44.556Z] [0007] CallstackAndLock..ctor leaving
[2013-05-21 14:26:44.556Z] [0007] CallstackAndLock..ctor entering
[2013-05-21 14:26:44.556Z] [0007] Session.DoDispose entering
[2013-05-21 14:26:44.556Z] [0007] Session.Cleanup entering
[2013-05-21 14:26:44.556Z] [0007] Disposing log readers
[2013-05-21 14:26:44.556Z] [0007] Session.Cleanup leaving
[2013-05-21 14:26:44.556Z] [0007] CPU Load [199.7649%]
[2013-05-21 14:26:44.556Z] [0007] Disposing logger, no more logging
Thanks for your help. I really like WinSCP so far. I removed the key, username, and password from the log above but I can connect using WinSCP without any problems. It is only the .net assembly that is causing some issues with log files.
Ken