How to Get Folder Size in VB6

Written by jim campbell
  • Share
  • Tweet
  • Share
  • Email

Visual Basic 6 (VB6) contains a class named "FileSystemObject" that retrieves the name of a folder and returns the size of the folder contents using the "GetFolder.Size" function. The code lets you automate file creation and check for existing drive and folder space to ensure that the program does not crash.

Skill level:

Other People Are Reading


  1. 1

    Click the Windows "Start" button and select "All Programs." Click "Microsoft Visual Basic" in the program groups, and then click "Visual Basic" to open the software.

  2. 2

    Click the "File" menu item, and then click "Open" to open a dialogue window. Click your Visual Basic project file name, and then click "Open" to load the code.

  3. 3

    Double-click the VB6 form to load it in the designer. Right-click the opened form and click "View Code" to view the form's code in the editor.

  4. 4

    Type the following code to retrieve the size of a folder:

    Dim filesystem As FileSystemObject

    Set filesystem = New FileSystemObject

    GetFolderSize = filesystem.GetFolder("c:\windows").Size

    Replace "C:\Windows" with the directory you want to view. The "GetFolderSize" variable contains the folder's size.

  5. 5

    Click "Save" in the main VB6 toolbar. Click "Run" to execute the code in the VB6 debugger.

Don't Miss

  • All types
  • Articles
  • Slideshows
  • Videos
  • Most relevant
  • Most popular
  • Most recent

No articles available

No slideshows available

No videos available

By using the site, you consent to the use of cookies. For more information, please see our Cookie policy.