Hi
Here is a variation using exactly the same code but wrapped in a loop to cycle through dates varying from now to now-11 days. The results are shown in the ListBox1.
Everything is as expected in this test.
The only thing I can think of is that you tried to use the example code I posted on the same file that you later tried with the amended code - the point being, the Creation date of the file may have been changed by the first trial and so was seen to be an 'old' file on later trials. When developing and testing, you should NEVER use actual data/files/things to test with, only use items specifically made for testing with (eg a COPY of a file). Also, you should never just copy/paste code from the forum and test on valid data without verifying that it is working correctly.
To try this code out on a TEST FILE, put a ListBox1 onto Form1 and run this code.
REMEMBER: there is code in this example to actually chane a file creation date so that the example works. You must not use the line containing 'SetCreationTime' on your own files.
Option Strict On
Option Explicit On
Public Class Form1
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
' test file path
Dim path As String = "C:\Users\lesha\Desktop\freddy.txt"
For i As Integer = 1 To 11
IO.File.SetCreationTime(path, Now.AddDays(-i))
Dim d As DateTime = IO.File.GetCreationTime(path)
If d.AddDays(10) <= Now Then
ListBox1.Items.Add("Create Date " & d.ToString & " Deleted")
Else
ListBox1.Items.Add("Create Date " & d.ToString & " NOT Deleted")
End If
Next
End Sub
End Class