process writes to its own log, but not with Process.start
I am running an exe program within my C# console program, which if I were
running it via the CMD, it would write to its own log, plus a few messages
to the CMD window. When I read the standardOutput within my program, I am
able to see the CMD messages, but the log to which the process should be
writing to is not being created. In other words, my external process
writes to its own log, which is built into this black box utility, so now
that I want to run it from my console program, the log is not being
created. Has anyone encountered this issue and have some suggestion as to
how it can be resolved? I cannot loose this log as it is the utility's
log; separate from my program. Here is a snipped of my code:
ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.CreateNoWindow = false;
startInfo.UseShellExecute = false;
startInfo.FileName = processName;
startInfo.RedirectStandardOutput = true;
startInfo.Arguments = " " + dbName + " " + pw + " " + clientFile;
try
{
using (Process exeProcess = Process.Start(startInfo))
{
using (StreamReader reader = exeProcess.StandardOutput)
{
string result = reader.ReadToEnd();
exeProcess.Start();
exeProcess.WaitForExit();
Console.WriteLine(result);
}
}
}
catch (Exception e)
{
Console.WriteLine("Error: " + e);
}
No comments:
Post a Comment