I am searching for a way to get the most recent file from a large directory. The directory contains images taken by a webcam. The only technique I have found (which works...but very slowly) is to get all the files using DirectoryInfo.GetFileSystemInfos. The approach is so slow that is unusable. I need to only retrieve the most recent. Any ideas?
Dim dir As New DirectoryInfo("c:/somepath")
Dim files As FileSystemInfo() = dir.GetFileSystemInfos()
' sort them by creation time
Array.Sort(Of FileSystemInfo)(files, Function(a As FileSystemInfo, b As FileSystemInfo) a.LastWriteTime.CompareTo(b.LastWriteTime)) ...
Go to the complete details ...