📊 VBA (Excel)

Report Size of The VS Code cache folder (VBA)

Reports the total size and top-level file count of the VS Code cache folder using Scripting.FileSystemObject, straight from Excel VBA.

By WindowsScripting.com · 708 B
VSCodeCacheSizeReport.bas
Attribute VB_Name = "VSCodeCacheSizeReport"
Option Explicit

Public Sub VSCodeCacheSizeReport()
    Dim fso As Object
    Dim folder As Object
    Dim folderPath As String

    folderPath = Environ("APPDATA") & "\Code\Cache"

    Set fso = CreateObject("Scripting.FileSystemObject")

    If Not fso.FolderExists(folderPath) Then
        MsgBox "Folder not found:" & vbCrLf & folderPath, vbExclamation
        Exit Sub
    End If

    Set folder = fso.GetFolder(folderPath)

    MsgBox "The VS Code cache folder" & vbCrLf & folderPath & vbCrLf & _
           "Size: " & Format(folder.Size / 1048576, "#,##0.00") & " MB" & vbCrLf & _
           "Files (top level): " & folder.Files.Count, vbInformation
End Sub