|
-
Oct 3rd, 2000, 04:10 AM
#1
Thread Starter
Member
Hello
I vould like to display date of file's last change in FileListBox near file name.
Can anybody help me?
Tomaz
-
Oct 3rd, 2000, 04:34 AM
#2
http://www.vbapi.com/ref/g/getfiletime.html
Has got what you want. The best I came up with (which may help or point you in the right direction is the following):
Code:
Private Declare Function GetFileTime Lib "kernel32.dll" _
(ByVal hFile As Long, lpCreationTime As FILETIME, _
lpLastAccessTime As FILETIME, lpLastWriteTime As FILETIME) As Long
Dim hFile As Variant ' handle to the opened file
Dim ctime As FILETIME ' receives time of creation
Dim atime As FILETIME ' receives time of last access
Dim mtime As FILETIME ' receives time of last modification
Dim thetime As SYSTEMTIME ' used to manipulate the time
Dim retval As Variant ' return value
Private Type FILETIME
dwLowDateTime As Long
dwHighDateTime As Long
End Type
Private 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 Integer
End Type
Private Declare Function FileTimeToLocalFileTime Lib "kernel32.dll" (lpFileTime As _
FILETIME, lpLocalFileTime As FILETIME) As Long
Private Sub File1_Click()
If File1.FileName <> "" Then
hFile = File1.FileName 'file selected from file list box
' Next, get the creation, last-access, and last-modification times.
retval = GetFileTime(hFile, ctime, atime, mtime)
' Convert the creation time to the local time zone.
retval = FileTimeToLocalFileTime(ctime, ctime)
' Convert the FILETIME format to the SYSTEMTIME format.
'retval = FileTimeToSystemTime(ctime, thetime)
' Display the date of creation of the file to the user.
Text1.Text = "The file was created on " & thetime.wMonth & "-" & thetime.wDay & "-" & thetime.wYear
End If
End Sub
Although I recieve an error at the "retval = GetFileTime(hFile, ctime, atime, mtime)" line, this is bloody close and I'm sure Kedaman or Megatron etc will point out the above anomolie to give you a proper example.
[Edited by alex_read on 10-03-2000 at 05:41 AM]
-
Oct 3rd, 2000, 04:50 AM
#3
Frenzied Member
put a listview
dirlistbox and file list box on a form
add 2 columns to the listview and set view as lvwReport
check Full Row Select (if you're using vb6)
set filelist as not visible
Code:
Option Explicit
Private Sub Dir1_Change()
File1.Path = Dir1.Path
End Sub
Private Sub File1_PathChange()
Dim itmx As ListItem
Dim i As Integer
ListView1.ListItems.Clear
For i = 0 To File1.ListCount - 1
Set itmx = ListView1.ListItems.Add(, , File1.List(i))
itmx.SubItems(1) = FileDateTime(File1.Path & "\" & File1.List(i))
Next i
End Sub
Private Sub Form_Load()
File1_PathChange
End Sub
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|