winscp.StartInfo.FileName = "C:\\Program Files (x86)\\WinSCP\\WinSCP.com";
System cannot find the file specified when I try to call an executable file in C#
Pergunta
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)"
Solução
Outras dicas
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.
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow