0
Answer

Console app wrapper help

mike

mike

17y
1.9k
1
I am currently tasked with providing a friendlier user interface here at work that will provided new features, but also will interact with several console apps. I need to be able to read/write to these applications. The key is being able to read and write multiple times to the same process.

I understand that I could use batch files for this but this will not provide the real-time feedback and interaction that I need to pull this off cleanly.

I am a former VB6 developer that has been using C# for a short time now. I have written similar applications to this one in VB6 using a DLL written by Franky Braem (http://www.codeproject.com/atl/redirect.asp). This worked great and is what I need to recreate in C#.

I have a code that is capable of reading and writing to the console using the System.Diagnostic namespace redirecting stdin, stdout and stderr (single thread). My issue with this code is that I have to close the StreamWriter of the process in order to read the stdout. Due to this when I attempt to send a subsequent string to the console I get an error that the TextWriter has been closed. Can I reopen this? I cannot locate anything on doing this.

I played with a second example written by Scott Hanselman (http://www.hanselman.com/blog/SoManyMistakesForMeToMakeSoLittleTimecapturingStandardErrorAndStandardOutput.aspx) that is multithreaded. This exhibits the same behavior described above.

In reality I would really like a C# version of Franky Braem's redirect DLL in C#. Any help here will be greatly appreciated!

Thanks