Writing to Standard Output from a Windows Forms application
- From: marc <marc.gibian@xxxxxxx>
- Date: Tue, 08 Aug 2006 14:55:16 -0700
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
.
- Prev by Date: Re: How to Https locally?
- Next by Date: RE: Click event getting lost during ColumnChanging event if modal dial
- Previous by thread: CHM file and webbrowser component
- Next by thread: RE: Click event getting lost during ColumnChanging event if modal dial
- Index(es):
Relevant Pages
|