Thursday, January 14, 2010

Print the size of the file and size on the disk

Dim fso, gfiles, filespec
filespec = "C:\Program Files\"
Set fso = CreateObject("Scripting.FileSystemObject")
Set gfiles = fso.GetFolder(filespec)
MyReturn = gfiles.Name & " Used:" & gfiles.Size & "Bytes"
MsgBox MyReturn

2 comments:

Code with Harry said...

Modified To get teh Folder Size in GB

Dim fso, gfiles, filespec
filespec = "C:\Program Files\"
Set fso = CreateObject("Scripting.FileSystemObject")
Set gfiles = fso.GetFolder("C:\\Data")
inGB=1024*1024*1024
MyReturn = gfiles.Name & " Folder Size=:" & gfiles.Size/inGB & "GB"
MsgBox MyReturn

Vinodh MD said...

Fine, Better we ll create new post for your code or suggestions

thank you
vinodh