I have program pro1.exe
that reads from input file, calculates result and writes it to output file.
Now I'm writing program test.exe
, that tests it on different tests (fill input, run pro1 using Process.Start()
and compares output with supposed)
Problem is following: after executing pro1.exe
output file is empty. However, if I run it manually, it writes to output file.
Here is code how I execute pro1:
ProcessStartInfo processInfo = new ProcessStartInfo();
processInfo.FileName = _applicationName;
processInfo.ErrorDialog = true;
processInfo.UseShellExecute = false;
processInfo.RedirectStandardOutput = true;
processInfo.RedirectStandardError = true;
Process proc = Process.Start(processInfo);
_applicationName
is a full path to exe file.
in debug I see, that process is starting, and ending without errors.
Start(String, String) Starts a process resource by specifying the name of an application and a set of command-line arguments, and associates the resource with a new Process component.
Start another application using your . NET code As a . NET method, Start has a series of overloads, which are different sets of parameters that determine exactly what the method does. The overloads let you specify just about any set of parameters that you might want to pass to another process when it starts.
This is often caused by having a different WorkingDirectory
. You likely need to set the WorkingDirectory
property to match the executable's path.
Without this, when UseShellExecute == false
, the working directory may not be the application's local path.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With