Size Method

For files, returns the size, in bytes, of the specified file.

Syntax

object.Size

Arguments

Object: Required. Always a File System Object.

Remarks

The following code illustrates the use of the Size method:

Example 1:

Function ShowFileSize(filespec)
   Dim fso, f, s
   Set fso = CreateObject("Scripting.FileSystemObject")
   Set f = fso.GetFile(filespec)
   s = " uses " & f.size & " bytes."
   ShowFileSize = s
End Function
'Usage
Dim FileSize
FileSize  = ShowFileSize("C:\Path\To\Your\File.txt")
'Output: If file size is 50 bytes then it returns uses 50 bytes.