471,310 Members | 1,017 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,310 software developers and data experts.

Find out if standard output is redirected?

MC
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?)

Jul 7 '08 #1
1 1661

"MC" wrote:
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?)

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]
Jul 7 '08 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

29 posts views Thread by chellappa | last post: by
1 post views Thread by Dirk Reske | last post: by
3 posts views Thread by ES Kim | last post: by
16 posts views Thread by Zenon | last post: by
2 posts views Thread by Michael B. Trausch | last post: by
1 post views Thread by terminatorul | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.