XbZ_SetFileDateTime()
Previous  Top  Next

XbZ_SetFileDateTime() - Set/Change the Date/Time Stamp of a File on Disk.

Syntax

XbZ_SetFileDateTime(<cFileName>,  
                    <cFatTimeDate>) --> lSuccess  

Parameters

<cFileName>  
<cFileName> contains the (relative or fully qualified) File Name (with or without Path) of the File that should be changed. If no Path or a relative Path is given, the file is searched for in the Current Directory of the Current Drive or in the given relative path from the Current Directory of the Current Drive.  

<cFatTimeDate>  
<cFatTimeDate> contains the FAT_Time_Date string that specifies the new Date/Time Stamp of <cFileName>.  

Returns

This functions returns .T. (TRUE) if the Date/Time Stamp of <cFileName> was successfully changed to <cFatTimeDate> or .F. (FALSE) if not.  

Description

This functions sets the UTC Date/Time of <cFileName> from the Local Date/Time given in the <cFatTimeDate> parameter (which must be in FAT_Time_Date format), and returns the success status of the operation. All three Date/Time Stamp values are changed by this function:  
 
·The Creation Date/Time,  
·The Last Changed Date/Time, and  
·The Last Access Date/Time.  
 
NOTE: This function does NOT work for Directories or any File that CANNOT be opened with Write Access!  
 
This is basically a wrapper function for the "Kernel32.dll" DLL Functions: SetFileTime(), DosDateTimeToFileTime(), and LocalFileTimeToFileTime().  

Example

Set the Date/Time Stamp (the Create, Last Update, and Last Access Dates/Times) of file "C:\Test\TestFile.abc" to the current System Date and Time:  

LOCAL cFileName := 'C:\Test\TestFile.abc'  
LOCAL cTimeDate := XbZ_DateTime2FatTimeDate(Date(), Time())  
LOCAL lSuccess  := XbZ_SetFileDateTime(cFileName, cTimeDate)