using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace clear
{
class Program
{
static void ClearFiles(string folderPath)
{
DateTime deleteThreshold = DateTime.Now.AddDays(-30); // 30 days ago
foreach (var file in new DirectoryInfo(folderPath).GetFiles())
{
if (file.CreationTime < deleteThreshold)
{
file.Delete();
}
}
}
static void Main(string[] args)
{
ClearFiles(@"d:\log");
Console.ReadKey();
}
}
}
C# 定期清理文件
最新推荐文章于 2024-05-17 17:58:06 发布