I have a base bit of code that I use to delete text files in a given directory:
For Each file As IO.FileInfo In New IO.DirectoryInfo(filePath).GetFiles("*.txt")
If (Now - file.CreationTime).Days > intdays Then file.Delete()
Next
filePath is the directory where the files are located.
intdays is a variable that determines how many days the files should be saved for.
To test the i code, set intdays to 0, assuming it will delete any files in directoy. However, this is not so, but does not create errors.
The time is "Now" # 2/8/2012 13:59:00 PM #, which is greater than 0. But I'm confused, why doesnβt it delete the file?
source
share