Google Groups Home
Help | Sign in
Find out if standard output is redirected?
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  2 messages - Collapse all
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
MC  
View profile
 More options Jul 6, 8:39 pm
Newsgroups: microsoft.public.dotnet.languages.csharp
From: "MC" <for.address.l...@www.ai.uga.edu.slash.mc>
Date: Sun, 6 Jul 2008 20:39:40 -0400
Local: Sun, Jul 6 2008 8:39 pm
Subject: Find out if standard output is redirected?
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?)

    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Morten Wennevik [ C# MVP ]  
View profile
 More options Jul 7, 3:24 am
Newsgroups: microsoft.public.dotnet.languages.csharp
From: Morten Wennevik [C# MVP] <MortenWenne...@hotmail.com>
Date: Mon, 7 Jul 2008 00:24:02 -0700
Local: Mon, Jul 7 2008 3:24 am
Subject: RE: Find out if standard output is redirected?

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


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2008 Google