delete files which are more than one month old using c#
-
30-09-2020 - |
문제
how to delete files which are more than one month old using c# script. i am using framework 2.0..
해결책
string path = @"C:\Temp\"; //"
DirectoryInfo dirInfo = new DirectoryInfo(path);
FileInfo[] fileInfos = dirInfo.GetFiles();
foreach (FileInfo fileInfo in fileInfos)
{
if (fileInfo.LastWriteTime < DateTime.Now.AddMonths(-1))
fileInfo.Delete();
}
다른 팁
You can call Directory.GetFiles
to find all files in a folder.
You can call File.GetLastWriteTime
to check when the file was modified.
You can call File.Delete
to delete a file.
제휴하지 않습니다 StackOverflow