title: MSMQ:Get the count of messages from MSMQ queue in remote machine
body: <p>I am trying to get the count of messages of a particular private queue in a remote machine.
  I am able to get the count from my local machine.</p>
  
  <p><strong>LocalMachine</strong>:</p>
  
  <p><code>path=@".\Private$\Sample";</code></p>
  
  <p><strong>RemoteMachine:</strong></p>
  
  <pre><code>Path=@"RemoteMachineName\Private$\Sample";
  </code></pre>
  
  <p><strong>Full Code:</strong></p>
  
  <p>When i try the remote machine path it throws me the error invalid path .</p>
  
  <p>I would appreciate if some one can guide me to the solution ?</p>
  
  <pre><code> var path ="FormatName:Direct=OS:RemoteMachineName\\private$\\sample";
  
   MessageQueue queuename = new MessageQueue(path);
   var mgmt = new MSMQManagement();
   object machine = "RemoteMachineName";
   object queuename = queue.Path;         
   object formatname = "Direct=OS";
   mgmt.Init(ref machine, ref queuename, ref formatname);
   int messageCount = mgmt.MessageCount;
   MessageBox.Show(string.Format("Queue has {0} items", messageCount));
  </code></pre>