' Collection of code snippets by Arne Vajhøj 
' (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) 
Imports System
Imports System.IO

Module Main
    Sub Main()
        Console.WriteLine(total("C:\WINNT"))
    End Sub
    Function total(dir As String) As Integer
        Dim res As Integer = 0
        Dim i As Integer
        Dim d As DirectoryInfo = new DirectoryInfo(dir)
        Dim allf As FileInfo() = d.GetFiles()
        For i = 0 To allf.Length - 1
            res = res + allf(i).Length
        Next
        Dim alld As DirectoryInfo() = d.GetDirectories()
        For i = 0 To alld.Length - 1
            res = res + total(alld(i).FullName)
        Next
        total = res
    End Function
End Module
