C# How do I use Directory.GetFiles() to get files that have the same order as in Windows explorer?

前端 未结 7 1099
萌比男神i
萌比男神i 2020-12-11 19:12

Is is possible to get files that is ordered same as in Windows Explorer

I know \"natural sort\", but it\'s not what I need, I need to get the file list ordered by th

7条回答
  •  Happy的楠姐
    2020-12-11 20:03

    using System.Linq;

    DirectoryInfo info = new DirectoryInfo(""); FileInfo[] files = info.GetFiles().OrderBy(p => p.CreationTime).ToArray(); foreach (FileInfo file in files) { // DO Something... }

    here is the sample code for get files in directory by creation time.

    You can get files by size same way.

提交回复
热议问题