DrDamnit
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?
ASKER
Date accessed, last time used, etc....
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, FindFirstChangeNotificatio n, FindNextChangeNotification to monitor folders and files.
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, FindFirstChangeNotificatio
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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.DateLastMod ified 'label to add: lblDateModified
Label4.Caption = "Last accessed: " & objFileDetails.DateLastAcc essed 'label to add: lblDateAccessed
End Sub
S
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
Label3.Caption = "Date modified: " & objFileDetails.DateLastMod
Label4.Caption = "Last accessed: " & objFileDetails.DateLastAcc
End Sub
S
ASKER
Chance for more points!!!
https://www.experts-exchange.com/questions/21381730/Add-Subtract-File-times.html
https://www.experts-exchange.com/questions/21381730/Add-Subtract-File-times.html
What do u mean by file usage status ?