Tech
Forums
Jobs
Books
Events
Live
Interviews
More
Learn
Training
Career
Members
Videos
News
Blogs
Post
An Article
A Blog
A Video
An Ebook
An Interview Question
Register
Login
7
Reply
List Generic - get some files
Dan
Jun 27 2013 5:06 PM
1.2k
Reply
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);
}
Upload Source Code
Select only zip and rar file.
Post
Reset
Cancel
Answers (
7
)
Next Recommended Forum
hide browser while running selenium test using c# driver.
Filestream