1

I have a requirement to delete all files in a directory, except for the 5 that were created the longest time ago. So if I have a directory with files that were created on.

11/6/2010, 11/5/2010, 11/4/2010, 11/3/2010, 11/2/2010, 11/1/2010

The only file to be deleted would be the one created on 11/6/2010. What is the best way to do this in ASP.NET?

Mike
  • 11,679
  • 16
  • 59
  • 85

1 Answers1

1

A link to get started: Sorting Directory.GetFiles()

Community
  • 1
  • 1
Tim Schmelter
  • 429,027
  • 67
  • 649
  • 891
  • Agreed. This thing called LINQ might just be the greatest thing to arrive in programming. Ever. – Mike Nov 13 '10 at 22:11