Previous Topic: GetFileStoreFree, GetFileStoreSize, and GetFileStoreUsage - Return the Free Space, Total Space, and Used SpaceNext Topic: GetLongFileName - Convert Short File Name to Long File Name


GetFileTime - Return File Creation Date, Last Access Date, or Last Modified Date

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

The GetFileTime function returns the creation date of a file (format 1), or, if the type of time is specified (format 2), the creation date, or last access date, or last modification date.

Function format:

GetFileTime(filename as String) as DateTime
GetFileTime(filename as String, type as Integer) as DateTime
filename

Specifies the name of the file to investigate.

type

Type of file time to retrieve.

The following values are valid:

0 Date and time of creation.

1 Date and time of last access.

2 Date and time of last modification (Default).

The DateTime structure is defined as follows:

Type DateTime
Year as Integer
Month as Integer
Day as Integer
DayOfWeek as Integer
Hour as Integer
Minute as Integer
Second as Integer
End Type

On successful completion, the function returns the creation date and time of a file (format 1), or the time specified in type (format 2). If the file does not exist, it returns a DateTime structure with all members set to -1.

Example:

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: