Thursday, June 6, 2013

Sorting by last modified date of files







 private static void GetFileDates()
        {
            DirectoryInfo di = new DirectoryInfo(_path);
            FileSystemInfo[] files = di.GetFileSystemInfos();
            var orderedFiles = files.OrderBy(f => f.LastWriteTime);
            FileSystemInfo first = (FileSystemInfo)orderedFiles.First();
            FileSystemInfo last = (FileSystemInfo)orderedFiles.Last();

            _startDate = first.LastWriteTime.ToString();
            _stopDate = last.LastWriteTime.ToString();

           
        }

No comments: