Writing to Standard Output from a Windows Forms application



I have a very simple Windows Forms application that I am enhancing to
also operate in command line mode. This seems simple enough... add some
command line arguments so the user can specify the desired behavior
without using the GUI and things should be fine. There is only one
problem... how do I get output back to the command line user? The
existing application writes the console with Console.WriteLine, but when
the application is a Windows Forms application, this just consumes the
output. It seems like the solution would be to set Console.Out to reset
the Console Out stream to the real standard output stream, but I can't
quite figure out how to do this. I realize Microsoft has made the
assumption that a Windows Forms application never has to write to
standard output, but this is not the first time I've had the need to do
precisely this. Any pointers (I'm afraid all of my searches have been
unsuccessful)?

Finally, if indeed this is not possible, how would you suggest I go
about implementing an application that can be driven either from command
line arguments or its GUI? One architecture that certainly would work
would be to have the intended command line be a console application, and
if no arguments are present, then launch a second application that is
the Windows Forms application. This certainly would work, but it sure
seems a very complex solution to what is really a simple application.

--
Sent via .NET Newsgroups
http://www.dotnetnewsgroups.com
.



Relevant Pages

  • RE: re-setting boot partition
    ... Description of the Windows 2000 Recovery Console ... For a Microsoft Windows XP version of this article, ... MB of hard disk space on your system partition to hold the Cmdcons folder ... Windows NTBoot Console Command Interpreter. ...
    (microsoft.public.win2000.setup_upgrade)
  • Re: Windows XP Crash
    ... then I tried to go in from windows, but without the proper msgina no way. ... How can I find the CD on console? ... the command you were having a problem with earlier --is REN ... (Do you have an installation CD? ...
    (microsoft.public.windowsxp.general)
  • Re: Help! Cant delete a file in Windows XP!
    ... I go into DOS (or rather the command prompt feature of WXP). ... When logged into Windows, ... New -> Task menu to run cmd.exe to load a console shell. ... Into its Recovery Console mode? ...
    (microsoft.public.windowsxp.basics)
  • RE: Win2000 Upgrade to SP3 Express Setup error.
    ... Start your computer with the Windows Setup floppy disks, ... MB of hard disk space on your system partition to hold the Cmdcons folder ... Windows NTBoot Console Command Interpreter. ... you cannot copy a file from the local hard disk to a floppy disk. ...
    (microsoft.public.win2000.setup_upgrade)
  • >>>> NET SEND <<<<
    ... Windows Xp Net Send ... Net Send Command For Mac ... Net Send Syntax Dos ... Dos Net Send Commands ...
    (sci.lang.japan)