FileDateTime Functions

Purpose

Returns a Date that indicates the date and time when a file was created, accessed or last modified.

Syntax

dt = FileDateTime ([Pathname$])

dt = FileDateTimeAccess ([Pathname$])

dt = FileDateTimeCreate ([Pathname$])

dt:Date

Description

The optional pathname argument is a string expression that specifies a file name. The pathname may include the directory or folder.

Without an argument the function returns the Date for the last file accessed using Dir().

Example

OpenW 1

Global d$, p1 As Int32

// Get the path for GfaWin32.exe

Local d$ = GetSetting("\\HKEY_CLASSES_ROOT\Applications\GfaWin32.exe\shell\open\command", , "")

If Left(d$, 1) = #34 Then d$ = Mid(d$, 2)

p1 = InStr(d$, #34) : If p1 <> 0 Then d$ = Left(d$, p1 - 1)

// Display File Date information

Print "GfaWin32.exe was created: "; FileDateTimeCreate(d$)

Print "The last time that GfaWin32.exe was modified or moved was: "; FileDateTime(d$)

Print "The last time that GfaWin32.exe was accessed was: "; FileDateTimeAccess(d$)

Print

// The same results can be achieved through the FileSystemObject

Global Object f, fs

Set fs = CreateObject("Scripting.FileSystemObject")

Set f = fs.GetFile(d$)

Print "GfaWin32.exe was created: "; f.DateCreated

Print "The last time that GfaWin32.exe was modified or moved was: "; f.DateLastModified

Print "The last time that GfaWin32.exe was accessed was: "; f.DateLastAccessed

Do : Sleep : Until Me Is Nothing

Set f = Nothing : Set fs = Nothing

CloseW 1

Remarks

Known Issues

FileDateTimeAccess doesn't always return a time when querying FAT32 files; this bug does not seem to affect FileDateTimeCreate or FileDateTime.

See Also

FileLen(), SetFileDateTime, SetFileDateTimeAccess, SetFileDateTimeCreate

{Created by Sjouke Hamstra; Last updated: 05/10/2014 by James Gaite}