Reputation: 12678
I have an .exe file, which is just a command line tool for a certain encryption. I have a .NET project and I want to include this with my program and be able to make command line calls to this exe and gets its response...
How can I include this .exe?
Upvotes: 1
Views: 382
Reputation: 20575
This can be quite easily achieved using the ProcessStartInfo.RedirectStandardOutput property. A full sample is contained in the linked MSDN documentation; the only caveat is that you may have to redirect the standard error stream as well to see all output of your application.
Process process = new Process();
process.StartInfo.FileName = "your_application.exe";
process.StartInfo.Arguments = "argument1 argument2 argument2 ...";
process.StartInfo.UseShellExecute = false;
process.StartInfo.RedirectStandardOutput = true;
process.Start();
Console.WriteLine(process.StandardOutput.ReadToEnd());
process.WaitForExit();
Upvotes: 3
Reputation: 1166
You can make a class library (DLL) that calls the executable's functions. Basically, you reference the created DLL in your other project. It acts as a middle man between your application and the other executable.
See here
Include the executable project in your class library project so you can call the encryption function.
Upvotes: 1