ASP.Net DirectoryInfo记录要进行排序和筛选

时间:2011-10-12 20:37:57

标签: asp.net visual-studio-2008 gridview directoryinfo

我想弄两行代码,但我似乎无法弄明白。

Dim filterFiles As FileInfo() = New DirectoryInfo(sPath).GetFiles().Where(Function(x) x.LastWriteTime >= (dtStartDate) AndAlso x.LastWriteTime <= (dtEndDate)).ToArray()

然后我想按日期对它们进行排序:

New DirectoryInfo(sPath).GetFiles().OrderByDescending(Function(x) x.CreationTime).ToArray()

如何合并两条线以在网格控件中显示?

1 个答案:

答案 0 :(得分:1)

这两行可以合并并作为您的DataSource提交。这假设.net 3.5。对不起,我写的是C#:

gridObject.DataSource = new DirectoryInfo(sPath).GetFiles().Where(x => x.LastWriteTime >= dtStartDate && x.LastWriteTime <= (dtEndDate)).OrderByDescending(x => x.LastWriteTime);