0

I write the next code that give me a list with the files in /DocXML.

I want is to get the file with the oldest creation date. How I can do?

Thanks for all.

private void button2_Click(object sender, EventArgs e)
{
    ftp.DownloadFile(textBox1.Text, textBox7.Text);
    FtpWebRequest request = (FtpWebRequest)WebRequest.Create("ftp://192.168.47.1/DocXML");
    request.Method = WebRequestMethods.Ftp.ListDirectory;
    request.Credentials = new NetworkCredential("username", "password");

    FtpWebResponse response = (FtpWebResponse)request.GetResponse();

    Stream responseStream = response.GetResponseStream();
    StreamReader reader = new StreamReader(responseStream);

    string names = reader.ReadToEnd();

    textBox12.Text = names; 
}
Gary Wright
  • 2,441
  • 1
  • 20
  • 32
garci
  • 87
  • 3
  • 8
  • Can you post an example what `reader.ReadToEnd()` returns? – Simon May 16 '15 at 11:59
  • I return this `Nuevo - copia (2).txt` `Nuevo - copia (3).txt` `Nuevo - copia (4).txt` `Nuevo - copia.txt` `Nuevo.txt` – garci May 16 '15 at 12:06
  • And do not ask the same question twice! [How can I download the oldest file of an FTP server?](http://stackoverflow.com/q/30280333/850848) – Martin Prikryl May 18 '15 at 06:58

0 Answers0