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;
            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).

I got the problem. The C# program was initiating the C++ program as if it were started from c:\. And since it couldn't find the required file there it was giving an error. But my question is this:

Is there any way to simulate to the [c++] program that it is being run from a specific directory? I know that windows shell passes the address of the program in the first argument, but is there any way I can set this argument?

I tried both, it did not work. So I decided to take the longer way out, by passing the directory as another argument, and then concatenating whatever file name I wanted in the c++ program.

Thank you