0
我想獲取特定目錄中的文件列表,然後我想檢查他們的最後修改日期。多個FTP請求 - C#
初始請求正常工作:
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();
然後一些處理之後,我選擇,我很感興趣的文件,並試圖找回自己的時間戳。下面以一個循環發生了:
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();
我FileDates
變量永遠不會被設置爲任何東西。我很想在一個類來包裝是爲了避免可怕的代碼重複,但現在我會滿足於能夠檢索我感興趣的數據
有沒有一個/在FtpPath的結尾? – 2010-12-16 21:52:47
@Scott Chamberlain是的。 – Radu 2010-12-16 22:34:56