I'm using FtpWebRequest to connect to an FTP server and I can use WebRequestMethods.Ftp.ListDirectoryDetails to list the directory details fine. However the response from the remote server has day, month and time but not year:
-rw-rw-rw- 1 user group 949 Jun 2 08:43 Unsubscribes_20100602.zip
-rw-rw-rw- 1 user group 1773 Jun 1 06:48 export_142571709.txt
-rw-rw-rw- 1 user group 1773 Jun 1 06:50 export_142571722.txt
-rw-rw-rw- 1 user group 980 Jun 1 06:51 export_142571734.txt
This is required for the application I'm writing so I tried to use WebRequestMethods.Ftp.GetDateTimestamp to get the datetimestamp for each file but the response is always empty. No exception is thrown.
try
{
FtpWebRequest ftp = (FtpWebRequest)WebRequest.Create(path);
ftp.Credentials = new NetworkCredential(_ftpUsername, _ftpPassword);
ftp.Method = WebRequestMethods.Ftp.GetDateTimestamp;
try
{
Stream stream = ftp.GetResponse().GetResponseStream();
StreamReader sReader = new StreamReader(stream);
return sReader;
}
catch (Exception exp)
{
throw new Exception(String.Format("An error occured getting the timestamp for {0}: {1}<br />", path, exp.Message));
}
}
Has anyone got any ideas why this would be?