How do I write to command line from a WPF application?

Posted by ben on Stack Overflow See other posts from Stack Overflow or by ben
Published on 2010-06-16T23:16:28Z Indexed on 2010/06/16 23:32 UTC
Read the original article Hit count: 183

Filed under:
|
|
|
|

Hi I know how to write to console but if I write to console in my program and call my program from the command line it won't display anything.

How do I make it so that when I say Console.WriteLine or Console.Out.Writeline ir prints to the command prompt from which it was called and not somewhere else?

Once again I know how to do Console.WriteLine so it's not that :-p unless I'm doing it wrong.

From what I can tell it's probably something to do with Console.SetOut(TextWriter t)

this is a WPF application and I need it to post its data to the command line while still retaining the GUI at startup. I've triple checked and my code hits the print lines, I can actually see the lines being printed to the Visual Studio output window, it just won't display in the command line when I run it manually without VS.

If possible I need to conditionally have the console display. ie if run from command line (or even with command arguments), display or post to the prompt, otherwise do not.

© Stack Overflow or respective owner

Related posts about c#

Related posts about wpf