Option Explicit
Private Type FILETIME
dwLowDateTime As Long
dwHighDateTime As Long
End Type
Private Declare Function SetFileTime Lib "kernel32" (ByVal hFile _
As Long, lpCreationTime As FILETIME, lpLastAccessTime As _
FILETIME, lpLastWriteTime As FILETIME) As Long
Private Declare Function GetFileTime Lib "kernel32" _
(ByVal hFile As Long, lpCreationTime As FILETIME, lpLastAccessTime As _
FILETIME, lpLastWriteTime As FILETIME) As Long
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 SystemTimeToFileTime Lib "kernel32" _
(lpSystemTime As SYSTEMTIME, lpFileTime As FILETIME) As Long
Private Declare Function FileTimeToSystemTime Lib "kernel32" _
(lpFileTime As FILETIME, lpSystemTime As SYSTEMTIME) As Long
Private Declare Function LocalFileTimeToFileTime Lib "kernel32" _
(lpLocalFileTime As FILETIME, lpFileTime As FILETIME) As Long
Private Declare Function FileTimeToLocalFileTime Lib "kernel32" _
(lpFileTime As FILETIME, _
lpLocalFileTime As FILETIME) As Long
Private Declare Function CreateFile Lib "kernel32" _
Alias "CreateFileA" _
(ByVal lpFileName As String, _
ByVal dwDesiredAccess As Long, _
ByVal dwShareMode As Long, _
ByVal lpSecurityAttributes As Long, _
ByVal dwCreationDisposition As Long, _
ByVal dwFlagsAndAttributes As Long, _
ByVal hTemplateFile As Long) As Long
Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As _
Long) As Long
Private Const OPEN_EXISTING = 3
Private Const FILE_ATTRIBUTE_NORMAL = &H80
Private Const GENERIC_READ = &H80000000
Private Const GENERIC_WRITE = &H40000000
Private Const FILE_SHARE_READ = &H1
Private Const FILE_SHARE_WRITE = &H2
Private Const FILE_FLAG_BACKUP_SEMANTICS = &H2000000
Private Const FILE_SHARE_DELETE As Long = &H4
Private Sub HitIt(myFil As String)
Dim hndFile As Long, st As SYSTEMTIME, ft As FILETIME, ftSystem As FILETIME
hndFile = CreateFile(myFil, GENERIC_READ Or GENERIC_WRITE, FILE_SHARE_READ _
Or FILE_SHARE_DELETE, 0&, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, 0&)
If hndFile = 0 Then Exit Sub
st.wYear = 2002 'Year
st.wDay = 25 'Day
st.wMonth = 12 'Month
st.wHour = 0 'Hour
SystemTimeToFileTime st, ft
LocalFileTimeToFileTime ft, ftSystem
SetFileTime hndFile, ftSystem, ftSystem, ftSystem
CloseHandle hndFile
End Sub
Sub Convrt()
Dim fso As Object, subFolders As Object, MyFl As String, folderObject As Object
MyFl = ("c:\temp\test") ''Set your Root Folder
HitIt (MyFl)
Set fso = CreateObject("Scripting.FileSystemObject")
Set subFolders = fso.GetFolder(MyFl).subFolders
For Each folderObject In subFolders
HitIt (MyFl & "\" & folderObject.Name)
Next
End Sub