title: How to get the last directory from a ftp url C#
body: <p>Is there a class or method in .NET 3.5 to get the last directory from a ftp Url?</p>
  
  <p>I have in a string variable the ftp url like this and in this case I want to retrieve Directory2</p>
  
  <pre><code>ftp://user:password@server:port/Directory1/Directory2
  </code></pre>
  
  <p>In this case the root</p>
  
  <pre><code>ftp://user:password@server:port/
  </code></pre>
  
  <p>I was trying to find something like Path.GetDirectoryName(string) but I can't find.</p>
  
  <p>I found that there is a way with Uri class and Segments.</p>
  
  <p>The longest will be split by "/" and verify that is not the "/" from ftp://</p>
  
  <p>There is another way already provided in .NET?</p>
  
  <p>Thanks.</p>