Sending pipe arguments to a C# application

前端 未结 1 1803
逝去的感伤
逝去的感伤 2021-01-13 16:32

I need to build an simple console application that accepts a pipe as input. We are running Windows Server 2012. The data is coming from another application that is going to

1条回答
  •  执念已碎
    2021-01-13 17:21

    When you use < and > with an application, the standard input and output streams (screen/keyboard interface) is replaced by a file stream.

    You can use the regular Console.Read and Console.ReadLine commands to read from the stream specified by the < directive, or use Console.In which is a TextReader.

    Similarly Console.Write and Console.WriteLine can be used to write to the output stream specified by the > directive, or Console.Out which is a TextWriter.

    If you use the | pipe directive, for example myapp.exe | sort, the output stream of the first program goes into the input stream of the next program.

    0 讨论(0)
提交回复
热议问题