获取目录列表中创建日期顺序.NET 3.0创建日期、顺序、目录、列表中

2023-09-04 06:57:18 作者:「你只会——属于我」

我需要的子目录列表,在订购CreationDate目录 .NET 3.0

I need to get list of sub-directories from a directory ordered by CreationDate in .Net 3.0

推荐答案

您应该能够使用 DirectoryInfo的类本(需要.NET 4):

You should be able to use the DirectoryInfo class for this (requires .NET 4):

var di = new DirectoryInfo(theFolder);
var directories = di.EnumerateDirectories()
                    .OrderBy(d => d.CreationTime)
                    .Select(d => d.Name)
                    .ToList();

在.NET 3.0中,你可以使用DirectoryInfo.GetDirectories,然后再把用同样的逻辑排序的数组。

In .NET 3.0, you could use DirectoryInfo.GetDirectories, then sort the array afterwards using the same logic.

 
精彩推荐
图片推荐