I am populating a datagrid control using files in a specified path (DirectoryInfo).
I would like to filter the files based on a user specified date range (start date & end date).
While search S/O, I found this post, but I am getting an error on DateComparer ("'DateComparer' is a type and cannot be used as an expression.")
Any other suggestions on how to filter by date?
Here is my code:
Dim dirInfo As New DirectoryInfo(strDirectoryPath)
Dim dStartDate As DateTime = "03/01/2011"
Dim dEndDate As DateTime = "6/30/2011"
Dim Files As FileInfo = dirInfo.GetFiles().Where(Function(Files) Files.CreationTime >= (dStartDate) AndAlso Files.CreationTime <= dEndDate)
datagrid.DataSource = Files
datagrid.DataBind()
On my test case prints out:
UPDATE (VB version):