var query=from file in Directory.GetFiles(source_path, filename, SearchOption.TopDirectoryOnly)
where File.GetLastWriteTime(file) >= DateTime.Now.AddHours(-1)
select file;
Console.Write(query.ToList().Count.ToString());
I’m using the above code to get the count of files modified in last one hour. Looking for a simpler solution. ie to have the count as part of the query itself.
Count()can take a predicate: