2

FTP のいくつかのファイルから日付と時刻を取得しようとしていますが、常に 1/1/0001 12:00:00 AM が返されます..なぜですか?

すべてが正常に動作しているように見えますが、何が間違っていますか?

for (int i = 0; i < lsnames.Count; i++)
 {
     ftpclient = (FtpWebRequest)WebRequest.Create(FTPPATH + lsnames[i].ToString());
     ftpclient.Credentials = new NetworkCredential("username", "password");
     ftpclient.UsePassive = true;
     ftpclient.UseBinary = true;
     ftpclient.KeepAlive = false;
     ftpclient.Method = WebRequestMethods.Ftp.ListDirectoryDetails;
     FtpWebResponse TimestampResponse = (FtpWebResponse)ftpclient.GetResponse();
     try { label2.Text = TimestampResponse.LastModified.ToString(); }
     catch { Label2Invocation(TimestampResponse.LastModified.ToString()); }
     Console.WriteLine("{0}", TimestampResponse.LastModified);
     MessageBox.Show("Dates: " + Convert.ToString(TimestampResponse.LastModified));
     TimestampResponse.Close();
 }
4

1 に答える 1

1

私も同じ問題を抱えていました。file.Modified は常に "1/1/0001 12:00:00 AM" を返します。パスの後にフィルターを追加すると、FtpListOption.Modifyfile.Modified は実際の時刻を返します... 驚きました。1分前にこれを見つけて、今アプリケーションで使用しています。

foreach (var file in ftpClient.GetListing(newpath, FtpListOption.Modify))
{
    //Console.WriteLine(file.Modified);

    if (file.Modified > lastRunTime)
    {
        //Download the file if it is newer than the last recorded run time.
        //WriteLine is for debugging purposes
        Console.WriteLine(file.Name);
    }
}
于 2014-05-28T14:47:14.257 に答える