📜  c# 删除超过 x 个月的文件 - C# 代码示例

📅  最后修改于: 2022-03-11 14:48:54.781000             🧑  作者: Mango

代码示例1
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();
}