List 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);
}

VulpesRank #55 · 29.2K reputationPosted Jun 27, 2013, 1:40 PM EDT
List
.Union(Directory.GetFiles(@"C:\folder1\", "*.pdf", SearchOption.AllDirectories))
.Where(x => File.GetLastAccessTime(x).Date.ToShortDateString() == DateTime.Today.Date.ToShortDateString())
.Select(x => x)
.ToList();
As it's certain that there won't be any duplicate file paths, you could also use Concat instead of Union - in fact, the former might be faster on folders which contain a lot of files.
Dan21 reputationPosted Jun 28, 2013, 1:05 AM EDT
EDIT: He duplicates the file because the folder path is not the same ( folder1 <> folder2 )
VulpesRank #55 · 29.2K reputationPosted Jun 28, 2013, 1:10 AM EDT
Are you saying that you want to amalgamate the files in the two folders but eliminate any duplicate files?
Dan21 reputationPosted Jun 28, 2013, 1:13 AM EDT
VulpesRank #55 · 29.2K reputationPosted Jun 28, 2013, 1:18 AM EDT
Dan21 reputationPosted Jun 28, 2013, 1:21 AM EDT
VulpesRank #55 · 29.2K reputationPosted Jun 28, 2013, 1:26 AM EDT