title: How to List Directory Contents with FTP in C#?
body: <p>How to List Directory Contents with FTP in C# ?</p>
  
  <p>I am using below code to List Directory Contents with FTP  it is returning result in XML format ,but i want only the name of directory not the whole content.</p>
  
  <p>How i Can do that ?</p>
  
  <pre><code>public class WebRequestGetExample
  {
      public static void Main ()
      {
          // Get the object used to communicate with the server.
          FtpWebRequest request = (FtpWebRequest)WebRequest.Create("ftp://www.contoso.com/");
          request.Method = WebRequestMethods.Ftp.ListDirectoryDetails;
  
          // This example assumes the FTP site uses anonymous logon.
          request.Credentials = new NetworkCredential ("anonymous","janeDoe@contoso.com");
  
          FtpWebResponse response = (FtpWebResponse)request.GetResponse();
  
          Stream responseStream = response.GetResponseStream();
          StreamReader reader = new StreamReader(responseStream);
          Console.WriteLine(reader.ReadToEnd());
  
          Console.WriteLine("Directory List Complete, status {0}", response.StatusDescription);
  
          reader.Close();
          response.Close();
      }
  }
  </code></pre>
  
  <p><a href="http://msdn.microsoft.com/en-us/library/ms229716.aspx" rel="noreferrer">MSDN</a></p>