C#按文件夹夹创建时间排序(顺序)

原文链接: www.baidu.com
 System.IO.DirectoryInfo dirInfo;
   dirInfo = new System.IO.DirectoryInfo("d:\\work\\");
DirectoryInfo[] myDirectoryInfo = dirInfo.GetDirectories();//目录类的对象数组,
SortAsFolderCreationTime(ref myDirectoryInfo);

       /// 
        /// C#按文件夹夹创建时间排序(顺序)
        /// 
        /// 待排序文件夹数组
        private void SortAsFolderCreationTime(ref DirectoryInfo[] dirs)
        {
            Array.Sort(dirs, delegate (DirectoryInfo x, DirectoryInfo y) {         return x.CreationTime.CompareTo(y.CreationTime); });
        }

你可能感兴趣的:(C#按文件夹夹创建时间排序(顺序))