Interesting. Anyone else found this? I have repeated this several times and am now questioning my process. Quite confusing.
I have a series of folders in c:\users\jp\appdata\temp\XXXX
Specifically:
"c:\users\jp\appdata\local\temp\dbgClean"
"c:\users\jp\appdata\local\temp\dbgWithDebug"
"c:\users\jp\appdata\local\temp\dbgSaveRaw "
"c:\users\jp\appdata\local\temp\tmp_TrackProcUsage "
Code:
' Author: Jack
' Date: 15-Jan-23
' ----------------------------------------------------------------
Sub DeleteTPUSessionFiles()
Dim fldr(3) As String
Dim i As Long
10 On Error Resume Next
20 fldr(0) = "tmp_TrackProcUsage"
30 fldr(1) = "dbgWithDebug"
40 fldr(2) = "dbgSaveRaw"
50 fldr(3) = "dbgClean"
Dim fso As FileSystemObject
60 Set fso = New FileSystemObject
70 For i = LBound(fldr) To UBound(fldr)
80 fso.DeleteFolder "c:\users\jp\appdata\local\temp\" & fldr(i)
90 Debug.Print Now & " deleted " & fldr(i)
100 Next
'CHECK TO MAKE SURE '
110 For i = LBound(fldr) To UBound(fldr)
120 Debug.Print i & " " & fldr(i) & String(15 - Len(fldr(i)), " ") & " EXISTS " _
& fso.FolderExists("c:\users\jp\appdata\local\temp\" & fldr(i)) & " " & Now
130 Next i
End Sub
And get the following result (regardless of where I position the "tmp_TrackProcUsage" in the array.
Code:
15-Jan-23 4:19:01 PM deleted tmp_TrackProcUsage
15-Jan-23 4:19:01 PM deleted dbgWithDebug
15-Jan-23 4:19:01 PM deleted dbgSaveRaw
15-Jan-23 4:19:01 PM deleted dbgClean
1 dbgWithDebug EXISTS False 15-Jan-23 4:19:01 PM
2 dbgSaveRaw EXISTS False 15-Jan-23 4:19:01 PM
3 dbgClean EXISTS False 15-Jan-23 4:19:01 PM
FSO FolderExists does not appear to deal with tmp_TrackProcUsage.
It will delete the folder and contents, but does not perform the FolderExists???
I have attached a gif file (Inside the zip) showing the process.
I could be overlooking something basic!