Hi,
I have a cce.exe program which I want to call it from C#. This program returns its output in TXT file.
Now I want to read this file and put it in process.StandardOutput.ReadToEnd()
Please help
Thanks in advance,
ProcessStartInfo psi = new ProcessStartInfo();
psi.FileName = "C:\\cce.exe";
psi.RedirectStandardOutput = true;
psi.UseShellExecute = false;
Process process = Process.Start(psi);
if (process.WaitForExit((int)TimeSpan.FromSeconds(10).TotalMilliseconds))
{
string bytes_result = process.StandardOutput.ReadToEnd(); ??? I should read txt file in put it in
bytes = Convert.ToDouble(bytes_result);
}
psi.FileName = "C:\\cce.exe";
psi.RedirectStandardOutput = true;
psi.UseShellExecute = false;
Process process = Process.Start(psi);
if (process.WaitForExit((int)TimeSpan.FromSeconds(10).TotalMilliseconds))
{
string bytes_result = process.StandardOutput.ReadToEnd(); ??? I should read txt file in put it in
bytes = Convert.ToDouble(bytes_result);
}
VulpesPosted Nov 1, 2014, 1:36 PM
Assuming you know the name of the file it creates, why don't you just wait for the program to exit and then read the file in the normal fashion?
ProcessStartInfo psi = new ProcessStartInfo();
psi.FileName = "C:\\cce.exe";
Process process = Process.Start(psi);
process.WaitForExit(10000);
string output = "";
if (process.HasExited)
{
output = System.IO.File.ReadAllText(somefilePath);
}
diamond diamondPosted Nov 1, 2014, 3:32 PM