I have a wierd problem running a process. pls have a look at this .
Hello Guys,
I am trying to run MSDOS fc.exe file using a process in C#. I have write down the following codes. I have also redirect the process's output so that i can read the output. The problem is when i run the program the following line of code suppose to return the output to the string s.
s=proc.StandardOutput.ReadToEnd().ToString();
But it didn't return. But the wired thing is when i debug the program it works fine. i have no idea where is the problem
the code is :
string s="ABBFHFF";
string workDir=@"C:\Test Projects\Accumulator";
System.Diagnostics.Process proc = new System.Diagnostics.Process();
proc.StartInfo.UseShellExecute=false;
//proc.EnableRaisingEvents=false;
proc.StartInfo.WorkingDirectory=workDir;
proc.StartInfo.FileName=@"fc";
proc.StartInfo.Arguments=@"C:\acc.xml C:\output.txt";
proc.StartInfo.WindowStyle=ProcessWindowStyle.Normal;
proc.StartInfo.RedirectStandardOutput=true;
try
{
//StreamReader sr=proc.StandardOutput;
proc.Start();
s=proc.StandardOutput.ReadToEnd().ToString();
MessageBox.Show(s);
MessageBox.Show(proc.StandardOutput.ReadToEnd());
proc.WaitForExit();
//MessageBox.Show(sr.ReadToEnd());
//sr.Close();
}
catch(Exception ex)
{
MessageBox.Show(ex.ToString());
}
MessageBox.Show(s.ToString());
For your kind informations fc is a dos program for comparing the content of the files. usually found in WIndows\System32 directory
Thanks