Results 1 to 3 of 3

Thread: File Date and Time

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Aug 2000
    Location
    Adelaide - Australia
    Posts
    150
    How do you return the creation and modification date and time of a file?

  2. #2
    Guest
    Use the FileDateTime function.

    Code:
    Msgbox FileDateTime("C:\file.exe")

  3. #3
    Lively Member
    Join Date
    Aug 2000
    Posts
    125
    Public Type WIN32_FIND_DATA
    dwFileAttributes As Long
    ftCreationTime As FILETIME
    ftLastAccessTime As FILETIME
    ftLastWriteTime As FILETIME
    nFileSizeHigh As Long '* ((MAXDWORD = 2,147,483,647) +1)
    nFileSizeLow As Long
    dwReserved0 As Long
    dwReserved1 As Long
    cFileName As String * MAX_PATH
    cAlternate As String * 14
    End Type

    Public Declare Function FindFirstFile _
    Lib "kernel32" Alias "FindFirstFileA" ( _
    ByVal lpFileName As String, _
    lpFindFileData As WIN32_FIND_DATA) As Long

    Public Declare Function FindNextFile _
    Lib "kernel32" Alias "FindNextFileA" ( _
    ByVal hFindFile As Long, _
    lpFindFileData As WIN32_FIND_DATA) As Long

    Public Declare Function FindClose Lib "kernel32" _
    (ByVal hFindFile As Long) As Long
    ===============================================

    Public Type FILETIME
    dwLowDateTime As Long
    dwHighDateTime As Long
    End Type

    Public Type SYSTEMTIME
    wYear As Integer
    wMonth As Integer
    wDayOfWeek As Integer
    wDay As Integer
    wHour As Integer
    wMinute As Integer
    wSecond As Integer
    wMilliseconds As Long
    End Type

    Public Declare Function FileTimeToSystemTime Lib "kernel32" (lpFileTime As FILETIME, lpSystemTime As SYSTEMTIME) As Long
    =============================================
    Private Function xFileDate(CT As FILETIME) As String

    Static ds As Single, ts As Single
    Dim ST As SYSTEMTIME

    If FileTimeToSystemTime(CT, ST) Then
    ds = DateSerial(ST.wYear, ST.wMonth, ST.wDay)
    ts = TimeSerial(ST.wHour, ST.wMinute, ST.wSecond)
    xFileDate = Format$(ds, "yyyy.mm.dd ") & Format$(ts, " hh:mm:ss")
    Else
    xFileDate = ""
    End If

    End Function

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width