Delete files over a week old

if (IsPostBack == false) {
 foreach (IO.FileInfo ActivityFileInfo in new IO.DirectoryInfo(Server.MapPath(".") + "\\ActivityFiles\\").GetFiles("*.txt")) {
  if (DateDiff(DateInterval.Day, ActivityFileInfo.CreationTime, Now) > 6) {
   ActivityFileInfo.Delete();
  }
 }
}

No comments:

Post a Comment