Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Find out if standard output is redirected?

0 views
Skip to first unread message

MC

unread,
Jul 6, 2008, 8:39:40 PM7/6/08
to
Is there a way to find out, from within a running C# console application,
whether its standard output has been redirected to a file? (Without
dropping down into Win32?)

Morten Wennevik [C# MVP]

unread,
Jul 7, 2008, 3:24:02 AM7/7/08
to

"MC" wrote:

Hi MC,

In .Net I think you are out of luck. Using Win32 I detected a change in
handle value when piping to file or not using the Kernel32 methods
GetStdHandle(STD_OUTPUT_HANDLE) and CreateFile("CON", ...).

--
Happy Coding!
Morten Wennevik [C# MVP]

0 new messages