2

Possible Duplicate:
How can I determine whether Console.Out has been redirected to a file?

Is there a way of telling whether the stdin stream to a console app is coming from the console or from a file using .Net?

I'm writing an app that should read from a file on the stdin if there is one but ideally shouldn't read from the stdin when it's just the user typing at the console.

Alternatively

Is there a way to detect when the user ends their typing at the console short of reading character by character and waiting for them to hit some app specific finished key combination?

Community
  • 1
  • 1
RobV
  • 28,022
  • 11
  • 77
  • 119
  • 2
    Is this any help? http://stackoverflow.com/questions/743885/how-can-i-determine-whether-console-out-has-been-redirected-to-a-file – bzlm Mar 05 '10 at 12:24
  • p/invoke'ing stuff is not any use to me since this needs to be able to run under Linux using Mono as well – RobV Mar 05 '10 at 12:53
  • Only one answer suggested the use of P/Invoke. Did you bother to scroll down to see the Reflection-based or Console-based solutions? :) – bzlm Mar 05 '10 at 12:56

0 Answers0