How to get all the files and their lengths from a directory 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)

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

    End Sub

End Module


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

 



answered Oct 18, 2018 by avibootz
...