Post a reply

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)


Topic review


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:

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:

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.