尝试使用LINQ按创建日期获取目录中的文件列表

l--*_*''' 5 c# linq

我想通过写日期获取目录中所有文件的列表:

private void Form1_Load(object sender, EventArgs e) {
  DateTime LastCreatedDate = 
               Properties.Settings.Default["LastDateTime"].ToDateTime();

  string [] filePaths = Directory.GetFiles(@"\\Pontos\completed\", "*_*.csv")
                        .OrderBy(p => System.IO.File.GetLastWriteTime(p))
                        .Where(p>=LastCreatedDate);
}
Run Code Online (Sandbox Code Playgroud)

问题

  1. 如何正确执行WHERE子句以仅获取大于或等于我的设置中的日期的文件?
  2. string []不适合这个,因为它不知道如何进行转换.我应该使用哪种数据类型?

Nov*_*kov 1

未经测试但应该可以工作:

private void Form1_Load(object sender, EventArgs e)
{
    DateTime LastCreatedDate = Properties.Settings.Default["LastDateTime"].ToDateTime();
    var filePaths = Directory.GetFiles(@"\\Pontos\completed\", "*_*.csv").Select(p => new {Path = p, Date = System.IO.File.GetLastWriteTime(p)})
        .OrderBy(x=>x.Date)
        .Where(x=>x.Date>=LastCreatedDate);

}
Run Code Online (Sandbox Code Playgroud)