title: Get file name from URI string in C#
body: <p>I have this method for grabbing the file name from a string URI. What can I do to make it more robust?</p>
  
  <pre><code>private string GetFileName(string hrefLink)
  {
      string[] parts = hrefLink.Split('/');
      string fileName = "";
  
      if (parts.Length &gt; 0)
          fileName = parts[parts.Length - 1];
      else
          fileName = hrefLink;
  
      return fileName;
  }
  </code></pre>