I have a program where i have a .exe file. The work of the .exe is to scan the directories for corrupted files. If accessed through the command prompt in the following format i get the result of scan
"location of exe" "files or folders to be scanned"
the result i get is as the scan goes on. Like
D:\A scanned
D:\B scanned
D:\C scanned
D:\D scanned
Now my question is how can i get the result line by line using c#.
I'm using the following set of codes by i get only the end result. I need the output line by line
The code is as follows:
string tempGETCMD = null;
Process CMDprocess = new Process();
System.Diagnostics.ProcessStartInfo StartInfo = new System.Diagnostics.ProcessStartInfo();
StartInfo.FileName = "cmd"; //starts cmd window
StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
StartInfo.CreateNoWindow = true;
StartInfo.RedirectStandardInput = true;
StartInfo.RedirectStandardOutput = true;
StartInfo.UseShellExecute = false; //required to redirect
CMDprocess.StartInfo = StartInfo;
CMDprocess.Start();
System.IO.StreamReader SR = CMDprocess.StandardOutput;
System.IO.StreamWriter SW = CMDprocess.StandardInput;
SW.WriteLine("@echo on");
SW.WriteLine(@"E:\Scanner\Scanner.exe -r E:\Files to be scanned\"); //the command you wish to run.....
SW.WriteLine("exit"); //exits command prompt window
tempGETCMD = SR.ReadToEnd(); //returns results of the command window
SW.Close();
SR.Close();
return tempGETCMD;
Any help in this would be apprecitated
Thanks,