title: Identify whether ftp URL is directory name or file using c#
body: <p>For a ftp path say <code>ftp://ftp.something.com/</code> I am able to list all directories with this code :</p>
  
  <pre><code>WebRequest req = WebRequest.Create(url) as WebRequest;
          req.Method = WebRequestMethods.Ftp.ListDirectory;
  
  //code to get response from ftp site and list all files and directories path in a list name name_list.
  </code></pre>
  
  <p>Now foreach path from a list name_list, if path is a directory then I add that path in a list name sub_list else if it is path of some file(.txt, .pdf, .rar, .html, .tw and many more extensions) then add that path in another list name final_list.
  So far what I am able to do is :</p>
  
  <pre><code>foreach(string url in name_list)
  {
   if (Regex.IsMatch(url, ".*?" + @"(\.[A-Za-z]{2,4}$)"))
           //add to sub_list
  else
          //add to final_list
  }
  </code></pre>
  
  <p>But this is not a reliable and robust way to achieve my goal.
  Is there any other best way to this.</p>