Home All Groups Group Topic Archive Search About

Redirection from stdin

Author
7 Mar 2006 2:20 PM
Stefano Del Furia
Hi all,
i must write a redirector that take some lines from stdin analyze it and 
put it on the stdout.
I have write something like this:

        static void Main(string[] args)
        {
            TextReader tIn = Console.In;
            TextWriter tOut = Console.Out;
            string text = null;
                while ( tIn.Peek() > 0 )
                {
                    text = tIn.ReadLine();
                    // analyze text
                    tOut.WriteLine(text);
                    tOut.Flush();
                }
        }

Is there a way to know when the stdin is closed ??
Thanks in advance
Stefano

AddThis Social Bookmark Button