Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Buy a domain name - Register cheap domain names from $0.99 - Namecheap

Scalable Hosting That Grows With You

Secure & Reliable Web Hosting, Free Domain, Free SSL, 1-Click WordPress Install, Expert 24/7 Support

Semrush - keyword research tool

Boost your online presence with premium web hosting and servers

Disclosure: My content contains affiliate links.

39,848 questions

51,769 answers

573 users

How to get all the files from a directory ordered by file size in windows with VB.NET

1 Answer

0 votes
Imports System.IO

Module Module1

    Sub Main()

        Dim dir As String = "d:\source\_working_frame\"

        Dim files() As String = Directory.GetFiles(dir)

        Dim sorted_by_len() As String = files.OrderByDescending(
                     New Func(Of String, Integer)(Function(filename As String)
                                                      Return New FileInfo(filename).Length
                                                  End Function)).ToArray

        For Each element As String In sorted_by_len
            Console.WriteLine("{0} {1}b", element, New FileInfo(element).Length)
        Next

    End Sub

End Module


' run:
' 
' d:\source\_working_frame\wf.exe 16046234b
' d:\source\_working_frame\sqlite3.dll 599419b
' d:\source\_working_frame\wf.res 138128b
' d:\source\_working_frame\wf.ico 137040b
' d:\source\_working_frame\workingframe.sqlite 98304b
' d:\source\_working_frame\link.res 25092b
' d:\source\_working_frame\wf_main.pas 8237b
' d:\source\_working_frame\sqlite3.def 4309b
' d:\source\_working_frame\wf_main.lfm 2698b
' d:\source\_working_frame\wf_main.compiled 495b
' d:\source\_working_frame\wf.lpr 365b
' d:\source\_working_frame\output.txt 0b
'...

 



answered Oct 19, 2018 by avibootz
...