我想通过写日期获取目录中所有文件的列表:
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)
问题
string []不适合这个,因为它不知道如何进行转换.我应该使用哪种数据类型?未经测试但应该可以工作:
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)
| 归档时间: |
|
| 查看次数: |
7168 次 |
| 最近记录: |