title: Download files from a server
body: <p>I am trying to get a list of files on a server</p>
  
  <p>CODE: </p>
  
  <pre><code>string ftpUserID = "user";
  string ftpPassword = "password";
  string ftpServerIP = "192.###.###.###";
  string remoteDirectory = @"\Update\UpdateTest";
  string localDirectory = @"C:\Updates";
  
  string[] downloadFiles;
  StringBuilder result = new StringBuilder();
  WebResponse response = null;
  StreamReader reader = null;
  
  FtpWebRequest reqFTP = (FtpWebRequest)FtpWebRequest.Create(new Uri("ftp://" + ftpServerIP + "/" +      remoteDirectory));
  reqFTP.UseBinary = true;
  reqFTP.Credentials = new NetworkCredential(ftpUserID, ftpPassword);
  reqFTP.Method = WebRequestMethods.Ftp.ListDirectoryDetails;
  reqFTP.EnableSsl = true;
  reqFTP.Proxy = null;
  reqFTP.KeepAlive = true;
  reqFTP.UsePassive = true;
  response = reqFTP.GetResponse();
  reader = new StreamReader(response.GetResponseStream());
  
  string line = reader.ReadLine();
  while (line != null)
  {
      result.Append(line);
      result.Append("\n");
      line = reader.ReadLine();
  }
  result.Remove(result.ToString().LastIndexOf('\n'), 1);
  return result.ToString().Split('\n');
  </code></pre>
  
  <p>I keep getting the WebException error saying 'Unable to connect to the remote server'</p>
  
  <p>This is as a result of errors in :</p>
  
  <pre><code> FtpWebRequest reqFTP = (FtpWebRequest)FtpWebRequest.Create(new Uri("ftp://" + ftpServerIP + "/" +      remoteDirectory));
  </code></pre>
  
  <p>Which is throwing a <strong>System.NotSuportedException</strong> on the <strong>reqFTP.Content</strong> and <strong>reqFTP.PreAuthenticate</strong> parts I think. </p>