Hello,
I am trying to do a simple console app to delete older files; it does
not work and the debugger does not see the mistake.
Any help would be greatly appreciated.
Sub Main()
On Error Resume Next
Dim oFSO
Dim sDirectoryPath
Dim oFolder
Dim oFileCollection
Dim oFile
Dim iDaysOld
Dim todaysdate
todaysdate = Now()
iDaysOld = 1
oFSO = CreateObject("Scripting.FileSystemObject")
sDirectoryPath = ("\\vs1\c:\temp")
oFolder = oFSO.GetFolder(sDirectoryPath)
oFileCollection = oFolder.Files
For Each oFile In oFileCollection
If oFile.DateLastModified < (todaysdate) - (iDaysOld) Then
oFile.Delete(True)
End If
Next
'Clean up
oFSO = Nothing
oFolder = Nothing
oFileCollection = Nothing
oFile = Nothing
End Sub