如何在.NET-4中创建NAMED-PIPE?

Rel*_*lla 4 c# .net-4.0

如何在C#应用程序中创建.NET-4中的NAMED-PIPE?

Chr*_*lor 8

下面是一段代码来创建命名管道客户端,它是从一个答案提升到刚才的问题我在使用命名管道C++和C#之间的通信回答

using System; 
using System.Text; 
using System.IO; 
using System.IO.Pipes; 

namespace CSPipe 
{ 
  class Program 
  { 
    static void Main(string[] args) 
    { 
      NamedPipeClientStream pipe = new NamedPipeClientStream(".", "HyperPipe", PipeDirection.InOut); 
      pipe.Connect(); 
      using (StreamReader rdr = new StreamReader(pipe, Encoding.Unicode)) 
      { 
        System.Console.WriteLine(rdr.ReadToEnd()); 
      } 

      Console.ReadKey(); 
    } 
  } 
}
Run Code Online (Sandbox Code Playgroud)