Answers for "c# delete files older than x months"

C#
1

c# delete files older than x months

using System.IO; 

string[] files = Directory.GetFiles(dirName);

foreach (string file in files)
{
   FileInfo fi = new FileInfo(file);
   if (fi.LastAccessTime < DateTime.Now.AddMonths(-3))
      fi.Delete();
}
Posted by: Guest on August-11-2020

Code answers related to "c# delete files older than x months"

C# Answers by Framework

Browse Popular Code Answers by Language