By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,418 Members | 1,430 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,418 IT Pros & Developers. It's quick & easy.

Find out if standard output is redirected?

P: n/a
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
Share this Question
Share on Google+
1 Reply


P: n/a

"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.