For some reporting purposes I'm trying to get the location of a certain binary.
I was doing this, and it was working, but I'm now getting a NullReferenceException when I try to get testProc.MainModule.FileName; and I think it may be that the program is closing before I'm able to grab it. Is there any better way to do this?
ProcessStartInfo testPSI = new ProcessStartInfo(RunOptions.TestBinary);
testPSI.RedirectStandardError = true;
testPSI.RedirectStandardOutput = true;
testPSI.UseShellExecute = false;
Process testProc = new Process();
testProc.StartInfo = testPSI;
testProc.Start();
ret = testProc.MainModule.FileName;
testProc.Kill();
if (ret != null)
return ret;