WinInet FTP Getting file creation date !!!!
Try using Currency variables instead. Everything should work after that. See
the example function below.
Hope it helps (and that I didn't forget anything),
Jonathan
----------
Private Const MAX_PATH& = 260
Private Type WIN32_FIND_DATA
dwFileAttributes As Long
ftCreationTime As Currency
ftLastAccessTime As Currency
ftLastWriteTime As Currency
nFileSizeHigh As Long
nFileSizeLow As Long
dwReserved0 As Long
dwReserved1 As Long
cFileName As String * MAX_PATH
cAlternate As String * 14
End Type
Private Declare Function FileTimeToLocalFileTime& Lib "kernel32" (lpFileTime
As Currency, lpLocalFileTime As Currency)
'-- Difference between day zero for VB and Win32 (12-30-1899, 01-01-1601)
Private Const DayZeroOffset As Double = 109205#
Private Const MillSecPerDay As Double = 10000000# * 60# * 60# * 24# / 10000#
Private Function TimeToVbTime(lpFileTime As Currency) As Date
'-- Call FindFirstFile() and then pass WIN32_FIND_DATA.ftCreationTime into
this function
Dim lpLocalFileTime As Currency
'-- Convert from UTC time to local time
If FileTimeToLocalFileTime(lpFileTime, lpLocalFileTime) Then
TimeToVbTime = CDate((lpLocalFileTime / MillSecPerDay) -
DayZeroOffset)
Else
'-- Check Err.LastDllError to find the prob
End If
End Function
Quote:
> Hi group !
> I'm working on a tedious bug since yesterday. I developped a Wininet
> Wrapper in VB 6.0.
> I have a function that get the files list of the FTP server (it use
> FtpFindFirstFile and FtpFindNextFile). We need to have the creation time
of
> each file. So theses functions fill a WIN32_FIND_DATA structure. The
> server on which i made the tests is IIS 5.
> The problem is that the creation time returned is always 0. I red in MSDN
> that i must convert this UTC format using FileTimeToLocalFileTime and
> FileTimeToSystemTime, but the last one fail everytime ! :( The message
> returned by GetLastError is "Parameter incorrect").
> But the previous call to FileTimeToLocalFileTime is working well !
> Any idea ?
> Thanks.