title: FTP list of directories only
body: <p>I'm trying to get list of directories from ftp but i'm not able to separate files from directories. </p>
  
  <p>So far i got this:</p>
  
  <pre><code>public static List&lt;string&gt; getDirs()
  {
      System.Net.FtpWebRequest ftpRequest = (System.Net.FtpWebRequest)System.Net.WebRequest.Create(path);
      ftpRequest.Credentials = new System.Net.NetworkCredential(name, pass);
      ftpRequest.Method = WebRequestMethods.Ftp.ListDirectory;
      System.Net.FtpWebResponse response = (System.Net.FtpWebResponse)ftpRequest.GetResponse();
      System.IO.StreamReader streamReader = new System.IO.StreamReader(response.GetResponseStream());
  
      List&lt;string&gt; directories = new List&lt;string&gt;();
      string line = streamReader.ReadLine();
      while (!string.IsNullOrEmpty(line))
      {
              directories.Add(line);
              line = streamReader.ReadLine();
      }
      streamReader.Close();
      return directories;
  }
  </code></pre>
  
  <p>and i got result like this:</p>
  
  <pre><code>folder1
  folder3
  file1.txt
  File2.dat
  folder2
  </code></pre>
  
  <p>Problem is, that i never know which one is directory and which one is file. I can't use regex to remove string from list where are dots or something like that because i can simply have folder named like "x.x"</p>
  
  <p>I find way where i can simply create folder with exact name i get from list. (if folder exists i get exception, if not i create folder) but this solution is not good enough for me.</p>
  
  <p>Is there any legit way how to get only directories list on FTP?</p>