We have a asp.net,C# application in which there is a requirement to get all the files whose date modified will be b/w startdate and enddate . How can we achieve this ? Also want to g开发者_如何学JAVAet all the files not modified for last 3 months ?
According to this post, you could do this:
var directory = new DirectoryInfo(your_dir);
DateTime from_date = DateTime.Now.AddMonths(-3);
DateTime to_date = DateTime.Now;
var files = directory.GetFiles()
.Where(file=>file.LastWriteTime >= from_date && file.LastWriteTime <= to_date);
look at this question and answer:
How to find the most recent file in a directory using .NET, and without looping?
you can start from there and add your where
clause to the provided LINQ query in the answer :)
精彩评论