title: How can I get a directory from a Uri
body: <p>For example, if I have</p>
  
  <blockquote>
    <p><a href="http://www.example.com/mydirectory/myfile.aspx" rel="noreferrer">http://www.example.com/mydirectory/myfile.aspx</a></p>
  </blockquote>
  
  <p>How can I get </p>
  
  <blockquote>
    <p><a href="http://www.example.com/mydirectory" rel="noreferrer">http://www.example.com/mydirectory</a></p>
  </blockquote>
  
  <p>I am looking for a .NET function call.</p>