Standard input and output in .NET.

How can I read from standard input and write to standard output. System.Diagnostics.Process.StandardInput The MSDN link did not help, since it separately starts the process and then redirects standard input / output, but what if the process is already running and called my application to transfer some data to it. Here is an example to make things a little clear:

I just use Unix channels, i.e. the cat command in cygwin (Linux as a windowing medium), which basically just reads standard input and prints to standard output. following command:

% cat input / sample.txt | Src / csharp / maptest

But that does not work.

If someone knows the ruby ​​here since I don't do this, I want to do the same in C #:

#!/usr/bin/env ruby 

STDIN.each_line 
do |line| 
some code here 
end

- , # vb.net:

#!/usr/bin/env python 

import re 
import sys 

for line in sys.stdin: 
val = line.strip() 

?

.

+3
3

System.IO.Pipes - .

, , , , . ,

dir /b /s c:\*.* | findstr exe

C:.

, , maptest, , , Console.Read*, . . .

#

+1

Console:

  • System.Console.In
  • System.Console.Out
+9

Console.ReadLine() Console.WriteLine()?

. System.IO.Pipes? MSDN.

0

Source: https://habr.com/ru/post/1772196/


All Articles