Previous Topic: GetFileAttributes - Return the File AttributesNext Topic: GetFileStoreFree, GetFileStoreSize, and GetFileStoreUsage - Return the Free Space, Total Space, and Used Space


GetFileSize - Return the Size of the File

Valid on NetWare, Symbian OS, UNIX, Windows and Windows CE

The GetFileSize function provides the size of the file in bytes.

This file content function has the format:

GetFileSize(filename as String) as Integer
filename

Identifies the path to the file.

The return value is the amount in bytes.

Example: GetFileSize function

This example reports the size and creation date of the file AUTOEXEC.BAT.

dim size as integer
dim time as DateTime
dim out as string

size=GetFileSize("C:\AUTOEXEC.BAT")
if (size<>-1) then
	 out="File size: "+chr(9)+chr(9)+str(size)+" bytes"+ chr(10)
	 time=GetFileTime("C:\AUTOEXEC.BAT")
	 out=out+"Creation date: "+chr(9)+str(time.month)+"/"+str(time.day)+"/"+str(time.year)
	 out=out+" "+str(time.hour)+":"+str(time.minute)+" "
	 MsgBox("Information on C:\AUTOEXEC.BAT"+chr(10)+chr(10)+out)

else
	 MsgBox("Cannot find C:\AUTOEXEC.BAT")
end if
end: