title: C# 3.5 - Connecting named pipe across network
body: <p>What is the correct way to setup a named pipe in C# across a network?</p>
  
  <p>Currently I have two machines, 'client' and 'server'.</p>
  
  <p>Server sets up its pipe in the following manner:</p>
  
  <pre><code>NamedPipeServerStream pipeServer = new NamedPipeServerStream(
      "pipe",
      PipeDirection.InOut,
      10,
      PipeTransmissionMode.Byte,
      PipeOptions.None)
  pipeServer.WaitForConnection();
  //... Read some data from the pipe
  </code></pre>
  
  <p>The client sets up its connection in the following manner:</p>
  
  <pre><code>NamedPipeClientStream pipeClient = new NamedPipeClientStream(
      "server",
      "pipe",
      PipeDirection.InOut);
  pipeClient.Connect(); //This line throws an exception
  //... Write some data to the pipe
  </code></pre>
  
  <p>The 'server' machine can be accessed on the network by going to "\\server".</p>
  
  <p>Whenever I run the program, I get a System.UnauthorizedAccessException that says "Access to the path is denied." The code works fine when I run the server and client on my local machine and attempt to connect to "." with the client.</p>