Question

I'm running a C# script in SSIS. In that script, I'm trying to call winSCP.com which is located in the following directory: "C:\Program Files (86)\WinSCP\"

But when I try to run the code, it always fails immediately.
Here is my code. what am I doing wrong?

// Run hidden WinSCP process

Process winscp = new Process();
winscp.StartInfo.WorkingDirectory = "C:\\Program Files (x86)\\WinSCP\\";
winscp.StartInfo.FileName = "winSCP.com";
winscp.StartInfo.UseShellExecute = false;
winscp.StartInfo.RedirectStandardInput = true;
winscp.StartInfo.RedirectStandardOutput = true;
winscp.StartInfo.CreateNoWindow = true;
winscp.Start();

The Error: "System.ComponentModel.Win32Exception: The system cannot find the file specified at System.Diagnostics.Process.StartWithCreateProcess(ProcessStartInfo startInfo)"

Was it helpful?

Solution

winscp.StartInfo.FileName = "C:\\Program Files (x86)\\WinSCP\\WinSCP.com";

OTHER TIPS

When you do not use shell execute. You must use the full path to the executed file. Because that in this case the working directory is not base directory to relative path. But just working folder for the executed file.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top