I have a program that generates a report, saves them to a directory (just in case), then emails it out to a specified list. What i'd like to do is delete the files that are more than a week or so old. I did some searching and found this script but i get an error.

VB Code:
  1. Dim ofile As File
  2.     Dim ofolder As Folder
  3.     Dim ofso As FileSystemObject
  4.     Set ofso = New FileSystemObject
  5.     Set ofolder = ofso.GetFolder("C:\temp")
  6.     [hl=#FFFF99]For Each ofile In ofolder[/hl]
  7.         If DateDiff("d", ofile.DateCreated, Now) > 7 Then
  8.             If Mid(ofile.ShortName, InStrRev(ofile.ShortName, ".")) = ".txt" Then
  9.                 ofile.Delete False
  10.             End If
  11.         End If
  12.     Next
  13.        Set ofile = Nothing
  14.     Set ofolder = Nothing
  15.     Set ofso = Nothing

The error i get is on the highlighted line. The Error i get is a message about object does not support this property or method.

Thanks
Andy