-1

How to call console application from FirstConsolApplication project, in SecondConsolApplication project? Everything is in same solution

   static void Main(string[] args)
        {
            using (Process p = new Process())
            {
                p.StartInfo = new ProcessStartInfo
                {
                    FileName = @"SecondConsolApplication.exe",
                    Arguments = "OneArgument",
                };
                p.EnableRaisingEvents = true;
                using (ManualResetEvent mre = new ManualResetEvent(false))
                {
                    p.Exited += (s, e) => mre.Set();
                    p.Start(); //ERROR IS HERE !
                    mre.WaitOne();
                }

                Console.WriteLine(p.StandardOutput.ReadToEnd());
            }
        }

I get exception:

The system cannot find the file specified

Raskolnikov
  • 3,791
  • 9
  • 43
  • 88
  • That path format requires the second executable to be in the working directory of the first one. Where _are_ both executables, relative to each other? – CodeCaster Aug 03 '15 at 08:46
  • I want that FirstConsolApplication work, after any change in SecondConsolApplication. I don't want to copy paste second executable to working directory of first project every time I change something. – Raskolnikov Aug 03 '15 at 08:50
  • **Where is** the second executable? It can be as simple as using `..\SecondProject\bin\Debug\SecondExecutable.exe`. Basic path logic. – CodeCaster Aug 03 '15 at 08:52
  • `FileName` give the Full path of the `exe` it will work.. – too_cool Aug 03 '15 at 08:55
  • @CodeCaster Can't be add as using, it is .exe (not .dll) – Raskolnikov Aug 03 '15 at 09:12

1 Answers1

1

You have to specify the full path to the .exe file or have to set the workingDirectory.

Community
  • 1
  • 1