Previous Topic: SetFileAttributes - Set the File AttributesNext Topic: Read and Compare File Versions


SetFileTime - Set the File or Directory Timestamps

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

The SetFileTime function sets the timestamps of a file or directory.

Function format:

SetFileTime(fileName as string, dateAndTime as DateTime, Type as integer) as Boolean
SetFileTime(fileName as string, dateAndTime as DateTime) as Boolean
fileName

Specifies the name of the file for which the date and time is to be modified.

dateAndTime

Identifies the new date and time to be set.

Type

Value 0; Creation date and time are modified (default).

Value 1; Last access file date and time are modified.

Value 2; Last modified file date and time are modified.

Value 3; Creation, last access, and final write date and time are modified.

On successful completion, the function returns TRUE; otherwise, returns FALSE.

Example:

Rem modify write time
Dim newTime as DateTime
newTime.year = 1999
newTime.month = 12
newTime.day = 31
newTime.hour = 23
newTime.minute = 59
newTime.second = 59
If Not(SetFileTime("c:\autoexec.bat",newTime,2)) Then
	Print ("SetFileTime failed")
	Exit
End If