XbZ_FileTime()
Previous  Top  Next

XbZ_FileTime() - Retrieve a File's Date/Time Stamp and Attributes from Disk.

Syntax

XbZ_FileTime(<cFileName>,  
             <@cAttrib>) --> cFAT_TimeDate  

Parameters

<cFileName>  
<cFileName> contains the (relative or fully qualified) File Name (with or without Path) of the File that should be checked. 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.  

<@cAttrib>  
After XbZ_FileTime() returns, <@cAttrib> will contain the File Attributes of <cFileName> as a (DOS) File Attribute Byte Value.  

Returns

This function returns the Date/Time Stamp of <cFileName> as a FAT_Time_Date string, and additionally updates <@cAttrib> with the DOS_File_Attribute Byte value. The Date/Time is converted to Local Date/Time from the original UTC Date/Time that is retrieved from Disk!  

Description

This function searches for <cFileName> and if the file is found, will return its Date/Time Stamp as a FAT_Time_Date string, and additionally updates <@cAttrib> with the DOS_File_Attribute Byte value. The Date/Time Stamp is converted to Local Date/Time from the original UTC Date/Time that is retrieved from Disk, and can be converted to an Xbase++ Date and Time value with the XbZ_FatTimeDate2DateTime() function. Similarly, the returned DOS_File_Attribute Byte value can be converted to a File Attribute string with the XbZ_DosAttrib2FileAttrib() function.  
 
This is basically a wrapper function for the "Kernel32.dll" DLL Functions: FindFirstFile(), FindClose(), FileTimeToLocalFileTime(), and FileTimeToDosDateTime().  
 
NOTE: The supported File Attributes are ONLY valid for MS DOS and Windows (FAT/VFAT/NTFS)!  

Example

Retrieve and display the current File Date/Time Stamp and the File Attributes of File "C:\Test\TestFile.abc":  

LOCAL cAttrib    := ''  
LOCAL cFileName  := 'C:\Test\TestFile.abc'  
LOCAL cFTimeDate := XbZ_FileTime(cFileName, @cAttrib)  
LOCAL aDateTime  := XbZ_FatTimeDate2DateTime(cFTimeDate)  
QOut('File Date of ' + cFileName + ' is: ' + DtoC(aDateTime[1]))  
QOut('File Time of ' + cFileName + ' is: ' + aDateTime[2])  
QOut('File Attributes of ' + cFileName + ' are: ' + ;  
      XbZ_DosAttrib2FileAttrib(cAttrib, '-'))