0 голосов
от в категории Студия

How to get latest file in folder

1 Ответ

0 голосов
от

List<System.IO.FileInfo>   of "*.txt" files order by descending last write time in folder "C:\\_TEST":

new System.IO.DirectoryInfo("C:\\_TEST").GetFiles("*.txt").OrderByDescending(o => o.LastWriteTime).ToList()

Latast File in folder:
new System.IO.DirectoryInfo("C:\\_TEST").GetFiles("*.txt").OrderByDescending(o => o.LastWriteTime).FirstOrDefault()