title: Get parent directory of parent directory
body: <p>I have a string relating to a location on a network and I need to get the directory that is 2 up from this location.</p>
  
  <p>The string could be in the format:</p>
  
  <pre><code>string networkDir = "\\\\networkLocation\\staff\\users\\username";
  </code></pre>
  
  <p>In which case I would need the <code>staff</code> folder and could use the following logic:</p>
  
  <pre><code>string parentDir1 = Path.GetDirectoryName(networkDir);
  string parentDir2 = Path.GetPathRoot(Path.GetDirectoryName(networkDir));
  </code></pre>
  
  <p>However, if the string is in the format:</p>
  
  <pre><code>string networkDir = "\\\\networkLocation\\users\\username";
  </code></pre>
  
  <p>I would just need the <code>networkLocation</code> part and <code>parentDir2</code> returns null.</p>
  
  <p>How can I do this?</p>
  
  <p>Just to clarify: In the case that the root happens to be the directory 2 up from the given folder then this is what I need to return </p>