WinInet FTP Getting file creation date !!!! 
Author Message
 WinInet FTP Getting file creation date !!!!

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.



Mon, 17 Feb 2003 20:33:12 GMT  
 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.



Mon, 17 Feb 2003 23:12:45 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. ftp with wininet and creation date

2. file creation date using ftp and Inet

3. Getting File Date/Time via FTP

4. FTP - Get File Date from FTP Site

5. File Creation Date/Time of an open file

6. FTP via WinInet APIs on NT4 + IIS 4: Delay before deleted files disappear

7. FTP GET with WinInet.DLL locks file for 45 seconds

8. How to get file size from FTP Server (WinInet.DLL)

9. FTP with WININET will cache files

10. FTP via WinInet APIs on NT4 + IIS 4: Delay before deleted files disappear

11. How to get file size from FTP Server (WinInet.DLL)

12. Getting File Creation Progress?

 

 
Powered by phpBB® Forum Software