Denise said:
Is it possible to make a VB code that can find the date modified on a
specific file saved on my network? If so how would I go about doing it? I
basically need a list of all the files in a particular folder and the date
they were last modified. So I can make other queries based on the dates.
Thanks,
Denise
The FileDateTime function should get you that information.
Here's some code I use to choose a directory and place it into a textbox:
'---begin Code behind form---
Private Sub cmdGetPath_Click()
'Opens a Treeview control that displays the directories in a computer
Dim lpIDList As Long
Dim sBuffer As String
Dim szTitle As String
Dim tBrowseInfo As BrowseInfo
szTitle = "This is the title"
With tBrowseInfo
.hWndOwner = Me.hwnd
.lpszTitle = lstrcat(szTitle, "")
.ulFlags = BIF_RETURNONLYFSDIRS + BIF_DONTGOBELOWDOMAIN
End With
lpIDList = SHBrowseForFolder(tBrowseInfo)
If (lpIDList) Then
sBuffer = Space(MAX_PATH)
SHGetPathFromIDList lpIDList, sBuffer
sBuffer = Left(sBuffer, InStr(sBuffer, vbNullChar) - 1)
If Right(sBuffer, 1) <> "\" Then sBuffer = sBuffer & "\"
txtSaveFileDirectory.Value = sBuffer
End If
End Sub
'----end Code behind form----
'---begin Module code---
'----Code from
http://support.microsoft.com/kb/179497
Public Const BIF_RETURNONLYFSDIRS = 1
Public Const BIF_DONTGOBELOWDOMAIN = 2
Public Const MAX_PATH = 260
Public Type BrowseInfo
hWndOwner As Long
pIDLRoot As Long
pszDisplayName As Long
lpszTitle As Long
ulFlags As Long
lpfnCallback As Long
lParam As Long
iImage As Long
End Type
Public Declare Function SHBrowseForFolder Lib "shell32" _
(lpbi As BrowseInfo) As Long
Public Declare Function SHGetPathFromIDList Lib "shell32" _
(ByVal pidList As Long, _
ByVal lpBuffer As String) As Long
Public Declare Function lstrcat Lib "kernel32" Alias "lstrcatA" _
(ByVal lpString1 As String, ByVal _
lpString2 As String) As Long
'----end Module code----
Once you have the directory you can use the Dir() function to get the
names of all the files in the directory. After that, you have what you
need to run the FileDateTime function on all the files in the directory.
James A. Fortune
(e-mail address removed)