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

smithochris

Got it, thanks - the link on stored sites/scripting helped me out.
And thanks for the recommendation on switching to the WinSCP.NET assembly. I'll look into that. As a side note, I went down the existing route based on this blog post by Tim Mitchell: https://www.timmitchell.net/post/2015/08/03/accessing-sftp-with-ssis/
martin

Re: Setting Working Directory Not Working as Expected

Please attach a full session log file showing the problem (using the latest version of WinSCP).

To generate the session log file, use /log=C:\path\to\winscp.log command-line argument. Submit the log with your post as an attachment. Note that passwords and passphrases not stored in the log. You may want to remove other data you consider sensitive though, such as host names, IP addresses, account names or file names (unless they are relevant to the problem). If you do not want to post the log publicly, you can mark the attachment as private.


Though for now, I will guess that you open a stored site in your script and that site has some local folder set (it's not recommended to use stored sites in scripting).

Btw, as you use C#, you should switch to WinSCP .NET assembly:
https://winscp.net/eng/docs/library
https://winscp.net/eng/docs/library_ssis
smithochris

Setting Working Directory Not Working as Expected

I have the following code to start the WinSCP process - this is being called in an SSIS C# script component:

Process winscp = new Process();
string logName = Dts.Variables["User::XMLLogLocation"].Value.ToString();

// Set the executable path and download directory
winscp.StartInfo.FileName = Dts.Variables["$Package::pWinSCPLocation"].Value.ToString();
winscp.StartInfo.WorkingDirectory = Dts.Variables["$Package::pDownloadDir"].Value.ToString();

// Set static execution options (these should not need to change)
winscp.StartInfo.UseShellExecute = false;
winscp.StartInfo.RedirectStandardInput = true;
winscp.StartInfo.RedirectStandardOutput = true;
winscp.StartInfo.CreateNoWindow = true;
winscp.StartInfo.Arguments = "/xmllog=\"" + logName + "\"";

Then the program runs a "synchronize local..." command to grab the appropriate files.

The issue I'm having is that the sync copies the new files to a directory that is different than what I've set in winscp.StartInfo.WorkingDirectory = Dts.Variables["$Package::pDownloadDir"].Value.ToString();

Any ideas on where/how the directory is changing? It goes 1 level deeper in the folder structure than I am specifying.