I created a generic string list, in which I want to add files from two different locations: from C:\folder1 and from C:\folder2. The files that I want to add, have .pdf extension and as comparation, must be accessed today. This is my code:
List<string> PDFiles = Directory.GetFiles("C:\folder1\", "*.pdf", SearchOption.AllDirectories).Where(x => File.GetLastAccessTime(x).Date.ToShortDateString() == DateTime.Today.Date.ToShortDateString())
.Select(x => x)
.ToList();
Now how can I add the next files, from C:\folder2 path? (with the same extension and comparation )?
I tried something like this, but I don't know if is such a good idea:
foreach (var test in Directory.GetFiles("C:\folder2\, "*.pdf", SearchOption.AllDirectories).Where(x => File.GetLastAccessTime(x).Date.ToShortDateString() == DateTime.Today.Date.ToShortDateString()))
{
PDFiles.Add(test);
}