Dim fso As Object, folder As Object, file As Object
Dim fil As Object
Dim strFileName As String
Dim strLastAccessedDate As String
Set fso = CreateObject("scripting.filesystemobject") '创建FSO对象
Set folder = fso.GetFolder(rootF)
For Each file In folder.Files
'遍历根文件夹下的文件
strFileName = rootF & file.Name
Set fil = fso.GetFile(strFileName)
strLastAccessedDate = fil.DateLastAccessed
If CDate(strLastAccessedDate) > (Now() - 90) Then
fso.DeleteFile strFileName, True
End If
' With fil
' Debug.Print "文件名:" & .Name
' Debug.Print "文件" & .Name & "的大小:" & .Size
' Debug.Print "文件" & .Name & "的类型:" & .Type
' Debug.Print "文件" & .Name & "的建立日期:" & .DateCreated
' Debug.Print "文件" & .Name & "的最后访问日期:" & .DateLastAccessed
' Debug.Print "文件" & .Name & "的最后修改日期:" & .DateLastModified
' Debug.Print "文件" & .Name & "所在驱动器:" & .Drive
' Debug.Print "文件" & .Name & "所在文件夹:" & .ParentFolder
' Debug.Print "文件" & .Name & "文件名(不支持长文件名):" & .ShortName
' Debug.Print "文件" & .Name & "完整路径(支持长文件名):" & .Path
' Debug.Print "文件" & .Name & "完整路径(不支持长文件名):" & .ShortPath
' End With
Next
Set fso = Nothing
Set folder = Nothing
Set fso = Nothing