Hello,
I have made a program in C++ for which I am making the GUI in C#. I want to run the C++ program as a process from C#. The program loads and runs fine, but due to some reason it is not able to access the files. When I run it externally using the same parameters, it works perfectly. Here is the c# code (the name of c++ program is TV.exe):
System.Diagnostics.Process proc = new System.Diagnostics.Process();
proc.StartInfo.FileName = CurrentDirectory + "TV.exe";
proc.StartInfo.Arguments = Convert.ToString(dataMain.Columns.Count - 3) + " " + Convert.ToString(dataMain.Rows.Count-1) + " 50 100";//command line arguments
proc.StartInfo.RedirectStandardOutput = true;
proc.StartInfo.UseShellExecute = false;
proc.StartInfo.CreateNoWindow = false;
proc.Start();
using (proc)
{
using (StreamReader reader = proc.StandardOutput)
{
string result = reader.ReadToEnd(); // Read in all the text from the process with the StreamReader.
rtbMessages.Text = result;
}
}
PS: I tried redirecting the output as well as not redirecting it, but the error reporter in my C++ program says that it is not able to access the file (I checked this using the good() function).