Show results in console
-
I want to output data to the console from a button click on my WinForms application. This is what I tried but with no call to the function aTest() was made.
Process myProcess = new Process(); myProcess.StartInfo.FileName = "cmd"; myProcess.StartInfo.Arguments = "aTest()"; myProcess.StartInfo.UseShellExecute = true; myProcess.Start();
Thanks Kash -
I want to output data to the console from a button click on my WinForms application. This is what I tried but with no call to the function aTest() was made.
Process myProcess = new Process(); myProcess.StartInfo.FileName = "cmd"; myProcess.StartInfo.Arguments = "aTest()"; myProcess.StartInfo.UseShellExecute = true; myProcess.Start();
Thanks KashWhat you've done won't work. You've put together a command line that looks like this:
CMD aTest()
Try typing that into a Start/Run box. You'll find that it does the exact same thing as your code.
CMD
doesn't know what to do withaTest()
because it's not a valid command line argument forCMD
.CMD
cannot call back into your code to execute a method. What I think you're trying to do is write to a console window that your application has complete control over. You can do this by redirecting the Streams of a CMD process. Check out this[^] article on MSDN, go about half way down the article, looking forControlling Console Apps with the Process Class
, and you'll see what I mean. RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome -
What you've done won't work. You've put together a command line that looks like this:
CMD aTest()
Try typing that into a Start/Run box. You'll find that it does the exact same thing as your code.
CMD
doesn't know what to do withaTest()
because it's not a valid command line argument forCMD
.CMD
cannot call back into your code to execute a method. What I think you're trying to do is write to a console window that your application has complete control over. You can do this by redirecting the Streams of a CMD process. Check out this[^] article on MSDN, go about half way down the article, looking forControlling Console Apps with the Process Class
, and you'll see what I mean. RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome