Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sorting files from directoryinfo by date in asp.net

how can I sort (not filter) directoryinfo files by date (oldest to recent) ? I am using asp.net and visual studio 2008

like image 697
Frank Avatar asked Dec 17 '22 08:12

Frank


1 Answers

The same as @DaRKoN_ in vb.net:

Module Module1

    Sub Main()
        Dim orderedFiles = New System.IO.DirectoryInfo("c:\\").GetFiles().OrderBy(Function(x) x.CreationTime)
        For Each f As System.IO.FileInfo In orderedFiles
            Console.WriteLine(String.Format("{0,-15} {1,12}", f.Name, f.CreationTime.ToString))
        Next
    End Sub

End Module
like image 70
apros Avatar answered Dec 30 '22 18:12

apros