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
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.
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.
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.
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.
Click "Save" in the main VB6 toolbar. Click "Run" to execute the code in the VB6 debugger.
- 20 of the funniest online reviews ever
- 14 Biggest lies people tell in online dating sites
- Hilarious things Google thinks you're trying to search for