I'm trying to get a listing of files in a specific directory and then I want to check their last modified dates.
Initial request works fine:
FtpWebRequest request;
request = (FtpWebRequest)WebRequest.Create(new Uri(FtpPath));
request.Credentials = new NetworkCredential("username", "password");
request.Method = WebRequestMethods.Ftp.ListDirectory;
FtpWebResponse response = (FtpWebResponse)request.GetResponse();
Stream responseStream = response.GetResponseStream();
StreamReader reader = new StreamReader(responseStream);
string FileNames = reader.ReadToEnd();
Then after some processing, I pick the files that I'm interested in and attempt to retrieve their time stamps. The following happens in a loop:
request = (FtpWebRequest)WebRequest.Create(new Uri(FtpPath + Files[i]));
request.Credentials = new NetworkCredential("username", "password");
request.Method = WebRequestMethods.Ftp.GetDateTimestamp;
response = (FtpWebResponse)request.GetResponse();
responseStream = response.GetResponseStream();
reader = new StreamReader(responseStream);
FileDates = reader.ReadToEnd();
My FileDates
variable never gets set to anything. I'd love to package this in a class to avoid the horrible code duplication but for now I would settle for being able to retrieve the data that I'm interested in.