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

前端 未结 7 1131
萌比男神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条回答
  •  情书的邮戳
    2020-12-11 20:01

    I guess you are talking about viewing pane in Windows Explorer (it's essentially a Windows File Manager but also known under different name). Some clarification is needed. You can apply your custom sorting on various columns; moreover, you can have multiple viewing panes (windows) open sorted on different columns. Thus, the problem definition is a bit unclear.

    Assuming that you know the sorting order in your viewing panes, then you can use System.IO.DirectoryInfo and derived FileSystemInfo[] objects; the latter has files.OrderBy method. Hope this will help. My best, Alex

提交回复
热议问题