Is there a more efficient way to populate a list of file names from a directory with a date filter?
Currently, I'm doing this:
foreach (FileInfo flInfo in directory.GetFiles())
{
DateTime yesterday = DateTime.Today.AddDays(-1);
String name = flInfo.Name.Substring(3,4);
DateTime creationTime = flInfo.CreationTime;
if (creationTime.Date == yesterday.Date)
yesterdaysList.Add(name);
}
This goes through every file in the folder, and I feel like there should be a more efficient way.