# Setting Working Directory Not Working as Expected

smithochris
Guest

## 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();

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.

martin
Joined:
Posts:
31,808
Location:
Prague, Czechia

## Re: Setting Working Directory Not Working as Expected

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.