Checking Standard Input in C#
I'm writing a small command line utility whose purpose is to parse the output of another utility. I want it to be invokable in two ways: c:\> myutility filewithoutput.txt Or, c:\> otherutility -args | myutility So, basically, standard in or a file argument. My first attempt at this looked like this: TextReader reader; if (args.Length > 1) { reader = new StreamReader(new FileStream(args[1], FileMode.Open)); } else { reader = Console.In; } Process(reader); The file argument works fine, and piping the output from the utility to my utility works fine, but if you just invoke it normally (no