Determine if File Is Old
Determines if a file is old. I use this when I loop through the files in a "temp" directory to determine if I should delete old files on a website. Take note - the function looks at the last modified date rather then the date created.
AI
Resumo por IA: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.
Código fonte
Private Sub Form_Load()
MsgBox IIf(FileIsOld("C:\AutoExec.bat"), "The file is old", "The file is new")
End Sub
Function FileIsOld(ByRef pStrFilePath As String) As Boolean
Dim llngMinutesOld As Long
Dim ldtmLastModified As Date
Dim llngFileAttr As VbFileAttribute
Const llngMinutesOldAfter As Long = 10
On Error Resume Next
llngFileAttr = FileSystem.GetAttr(pStrFilePath)
If Err Then
MsgBox "File does not exist."
Exit Function ' file doesn't exist
End If
On Error GoTo 0
If Len(FileSystem.Dir(pStrFilePath, llngFileAttr)) = 0 Then Exit Function
ldtmLastModified = FileSystem.FileDateTime(pStrFilePath)
llngMinutesOld = DateDiff("n", ldtmLastModified, Now())
FileIsOld = llngMinutesOld > pLngMinutesOldAfter
End Function
Comentários originais (3)
Recuperado do Wayback Machine