Page 1 of 1

How to Open a Directory Sorted by Date?

Posted: Tue Jun 01, 2010 3:53 am
by complete
How to Open a Directory Sorted by Date?

In C#, I can open a directory for reading each file. How to I make sure that the directory I investigate in my C# code is opened such that it is sorted by last modified date?

Posted: Sun Jul 24, 2022 6:52 pm
by rapidfirerocks
it was this that brought me to speedguide so only fitting I drop the answer...

DirectoryInfo info = new DirectoryInfo("DIRECTORY_PATH");
FileInfo[] files = info.GetFiles().OrderBy(p => p.CreationTime).ToArray();

:)