Skip to content
David Kittell
David Kittell

Application & System: Development / Integration / Orchestration

  • Services
    • Application Development
    • Online Application Integration
  • Code
  • Online Tools
  • Tech Support
David Kittell

Application & System: Development / Integration / Orchestration

Get Folder Size

Posted on December 14, 2013October 26, 2015 By David Kittell
Function GetFolderSize(ByVal DirPath As String, _
    Optional ByVal IncludeSubFolders As Boolean = True) As Long

        Dim lngDirSize As Long
        Dim objFileInfo As FileInfo
        Dim objDir As DirectoryInfo = New DirectoryInfo(DirPath)
        Dim objSubFolder As DirectoryInfo

        Try

            'add length of each file
            For Each objFileInfo In objDir.GetFiles()
                lngDirSize += objFileInfo.Length
            Next

            'call recursively to get sub folders
            'if you don't want this set optional
            'parameter to false
            If IncludeSubFolders Then
                For Each objSubFolder In objDir.GetDirectories()
                    lngDirSize += GetFolderSize(objSubFolder.FullName)
                Next
            End If

        Catch Ex As Exception


        End Try

        Return lngDirSize
    End Function
Originally Posted on December 14, 2013
Last Updated on October 26, 2015
All information on this site is shared with the intention to help. Before any source code or program is ran on a production (non-development) system it is suggested you test it and fully understand what it is doing not just what it appears it is doing. I accept no responsibility for any damage you may do with this code.

Related

Code VB.NET

Post navigation

Previous post
Next post

Related Posts

PowerShell – Get Text Encoding Type

Posted on June 16, 2020August 17, 2024

function Get-Encoding { param ( [Parameter(Mandatory,ValueFromPipeline,ValueFromPipelineByPropertyName)] [Alias(‘FullName’)] [string] $Path ) process { $bom = New-Object -TypeName System.Byte[](4) $file = New-Object System.IO.FileStream($Path, ‘Open’, ‘Read’) $null = $file.Read($bom,0,4) $file.Close() $file.Dispose() $enc = [Text.Encoding]::ASCII if ($bom[0] -eq 0x2b -and $bom[1] -eq 0x2f -and $bom[2] -eq 0x76) { $enc = [Text.Encoding]::UTF7 } if ($bom[0]…

Read More

Convert Text to VarChar

Posted on July 10, 2013October 26, 2015

CONVERT(varchar(8000),col1) Example: IP is varchar(50) and Hostname is Text Not sure why you would ever have a need for this but this is an example that works. SELECT id ,DATETIME ,(‘IP Address:’ + ipaddress) AS "IP Address" ,(‘Hostname: ‘ + CONVERT(VARCHAR(8000), hostname)) AS "Hostname" FROM pageview More practical use SELECT…

Read More

Test Password Strength

Posted on February 2, 2015October 26, 2015

$(‘#pass’).keyup(function(e) { var strongRegex = new RegExp("^(?=.{8,})(?=.*[A-Z])(?=.*[a-z])(?=.*[0-9])(?=.*\W).*$", "g"); var mediumRegex = new RegExp("^(?=.{7,})(((?=.*[A-Z])(?=.*[a-z]))|((?=.*[A-Z])(?=.*[0-9]))|((?=.*[a-z])(?=.*[0-9]))).*$", "g"); var enoughRegex = new RegExp("(?=.{6,}).*", "g"); if (false == enoughRegex.test($(this).val())) { $(‘#passstrength’).html(‘More Characters’); } else if (strongRegex.test($(this).val())) { $(‘#passstrength’).className = ‘ok’; $(‘#passstrength’).html(‘Strong!’); } else if (mediumRegex.test($(this).val())) { $(‘#passstrength’).className = ‘alert’; $(‘#passstrength’).html(‘Medium!’); } else { $(‘#passstrength’).className =…

Read More

Code

Top Posts & Pages

  • PowerShell - Rename Pictures to Image Taken
  • Front Page
  • C# - Start/Stop/Restart Services
  • MacPorts / HomeBrew - Rip CD tracks from terminal
  • PowerShell - Show File Extensions

Recent Posts

  • Javascript – Digital Clock with Style
  • BASH – Web Ping Log
  • BASH – Picture / Video File Name Manipulation
  • Mac OSX Terminal – Create SSH Key
  • Bash – Rename Picture

Top Posts

  • PowerShell - Rename Pictures to Image Taken
  • C# - Start/Stop/Restart Services
  • MacPorts / HomeBrew - Rip CD tracks from terminal
  • PowerShell - Show File Extensions
©2025 David Kittell | WordPress Theme by SuperbThemes