How to Delete folder older than 7 days C# / NET

.net, c#, visual-studio-2010, winforms

Solution

You can lookup using the DirectoryInfo util

   DirectoryInfo d = new DirectoryInfo(dir);
   if (d.CreationTime    < DateTime.Now.AddDays(-7))
       d.Delete();

Problem

I want to write some code that deletes all DIRECTORIES older than 7 days. So: - Check directory : `D:\this` - If folder older than 7 days -> delete it from the system.

Original source

Related problems