Search code examples
.netprocessexecution

running .net console applications programmatically


I have a .exe program (console app) written in .net.

  1. I need to execute it
  2. Provide inputs
  3. Get the outputs as a string or preferably as stream.

Currently I'm using System.Diagnostics namespace and Process Class. But using Diagnostic namespace for this purpose dosent seem to be ok.

Is there any method by which I can do the same thing more efficiently?. Like using reflection to find Main() method and then invoking it.


Solution

  • The Process class is exactly the right tool for doing what you want. Don't mind the name of the Diagnostic namespace - just use the Process class.