Link to home
Start Free TrialLog in
Avatar of DrDamnit
DrDamnitFlag for United States of America

asked on

Access NTFS data / record file usuage stats

I need to know if there is a way in VB to record / monitor file usage stats. Any ideas?
Avatar of Shiju S
Shiju S
Flag of United States of America image

hi
What do u mean by file usage status ?
Avatar of DrDamnit

ASKER

Date accessed, last time used, etc....
Avatar of RainUK
RainUK

API function to read the file date/time stamp for all 3 date/times

Private Declare Function GetFileTime Lib "kernel32" (ByVal hFile As Long, lpCreationTime As FileTIME, lpLastAccessTime As FileTIME, lpLastWriteTime As FileTIME) As Long

You can also use the APIs, FindFirstChangeNotification, FindNextChangeNotification to monitor folders and files.
ASKER CERTIFIED SOLUTION
Avatar of mladenovicz
mladenovicz

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Set a reference to Microsoft Scripting Runtime, locate a command button and 4 labels on your form:

Private Sub Command1_Click()
Call Get_Last_Accessed("your path&filename")
End Sub

Private Sub Get_Last_Accessed(ByVal fFile As String)
Dim objFSO As New FileSystemObject
Dim objFileDetails As File

Set objFileDetails = _
objFSO.GetFile(fFile)

Label1.Caption = "File type: " & objFileDetails.Type 'label to add: lblFileType
Label2.Caption = "Date created: " & objFileDetails.DateCreated 'label to add: lblDateCreated
Label3.Caption = "Date modified: " & objFileDetails.DateLastModified 'label to add: lblDateModified
Label4.Caption = "Last accessed: " & objFileDetails.DateLastAccessed 'label to add: lblDateAccessed
End Sub

S