Finally, to take another approach that may do better in your case.
Here is some code that use FindFirstFile_()
It is also shorter...
Code:
;Read "File Times and Daylight Saving Time" at https://docs.microsoft.com/en-us/windows/win32/sysinfo/file-times
;_____________________________________________________________________________
Procedure.s WinError(ErrorCode.L)
Protected *BStr
Protected *BStrData.String
Protected.s ErrorMessage
Protected.l ErrorLen
ErrorLen = FormatMessage_(#FORMAT_MESSAGE_FROM_SYSTEM | #FORMAT_MESSAGE_ALLOCATE_BUFFER,
#Null$, ErrorCode, #Null$, @*BStr , #Null$, #Null$)
If ErrorLen
*BStrData.String = @*BStr
ErrorMessage = *BStrData\s
LocalFree_(*BStr)
ProcedureReturn("Error " + Str(ErrorCode) + " (0x" + Hex(ErrorCode) + ") : " + Left(ErrorMessage, ErrorLen - 2))
Else
ProcedureReturn("Unknown error " + Str(ErrorCode) + " (0x" + Hex(ErrorCode) + ")")
EndIf
EndProcedure
;_____________________________________________________________________________
Procedure.s FileTimeToInternationalTime(File_Time)
Protected Sys_Time.SystemTime
FileTimeToSystemTime_(File_Time, @Sys_Time)
ProcedureReturn(Str(Sys_Time\wyear) + "-" + RSet(Str(Sys_Time\wMonth), 2, "0") + "-" +
RSet(Str(Sys_Time\wDay) , 2, "0") + " " + RSet(Str(Sys_Time\wHour), 2, "0") + ":" +
RSet(Str(Sys_Time\wMinute), 2, "0") + ":" + RSet(Str(Sys_Time\wSecond), 2, "0"))
EndProcedure
;______________________________________________________________________________
Define zExeName.s{#MAX_PATH}
Define zFileSystem.s{20}
Define zDrive.s{4}
Define.s sBuffer
Define.i hFile
Define.l LastError
Define.FILETIME LastWriteTime
Define.FILETIME FileTimeLocal
Define.SYSTEMTIME SystemTimeLocal
Define.TIME_ZONE_INFORMATION TimeZoneInfo
Define.WIN32_FIND_DATA FileData ;File data structure
If GetTimeZoneInformation_(TimeZoneInfo) = #TIME_ZONE_ID_DAYLIGHT
sBuffer = sBuffer + "Daylight saving is on"
Else ;#TIME_ZONE_ID_STANDARD
sBuffer = sBuffer + "Daylight saving is off"
EndIf
sBuffer = sBuffer + #CRLF$ + #CRLF$ + "Daylight saving offset is " + Str(TimeZoneInfo\DaylightBias) + " minutes" + #CRLF$ + #CRLF$
zExeName = ProgramFilename()
;If you want to get the parent folder else REM those two lines
zExeName = GetPathPart(zExeName) ;To get folder only
zExeName = Left(zExeName, Len(zExeName) -1) ;Remove last backslash
zDrive = Left(zExeName, 3)
GetVolumeInformation_(zDrive, 0, 0, 0, 0, 0, @zFileSystem, SizeOf(zFileSystem))
sBuffer = sBuffer + "File system for " + Left(zExeName, 3) + " is " + zFileSystem + #CRLF$ + #CRLF$
sBuffer = sBuffer + "File name is " + zExeName + #CRLF$ + #CRLF$
hFile = FindFirstFile_(zExeName, @FileData) ;Get files or folders
If hFile <> #INVALID_HANDLE_VALUE ;Make sure we have a valid handle
LastWriteTime = FileData\ftLastWriteTime ; \ftCreationTime \ftLastAccessTime \ftLastWriteTime
FindClose_(hFile)
Else
LastError = GetLastError_()
sBuffer = sBuffer + "FindFirstFile_ error: " + WinError(LastError) + #CRLF$ + #CRLF$ ;Show it in readable text
EndIf
FileTimeToSystemTime_(LastWriteTime, @SystemTimeLocal) ;Convert to local time part A
SystemTimeToTzSpecificLocalTime_(#Null, SystemTimeLocal, @SystemTimeLocal) ;Convert to local time part B
SystemTimeToFileTime_(SystemTimeLocal, @FileTimeLocal) ;Convert to local time part C
sBuffer = sBuffer + "Local last write file time is " + FileTimeToInternationalTime(FileTimeLocal)
MessageBox_(#HWND_DESKTOP, sBuffer + #CRLF$, "File time", #MB_OK | #MB_TOPMOST)
;______________________________________________________________________________
;