Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

c# delete files older than 10 days

using System.IO; 

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

foreach (string file in files)
{
   FileInfo fi = new FileInfo(file);
   if (fi.LastAccessTime < DateTime.Now.AddDays(-10))
      fi.Delete();
}
Comment

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();
}
Comment

PREVIOUS NEXT
Code Example
Csharp :: how to set the fps in monogame 
Csharp :: get max enum value c# 
Csharp :: get unix time in seconds C# 
Csharp :: c# unix timestamp 
Csharp :: unity player look at mouse 
Csharp :: c# random color 
Csharp :: get application path c# 
Csharp :: loop through enum c# 
Csharp :: c# loop through datatable 
Csharp :: unity textmeshpro 
Csharp :: asp.net core get request ip address 
Csharp :: unity get speed of object 
Csharp :: create new gameobject unity 
Csharp :: new Color from hex in unity 
Csharp :: c# get display resolution 
Csharp :: unity look at 2d 
Csharp :: dotnet dev-certs https --clean 
Csharp :: c# how to add newline on text box 
Csharp :: get all files in all subdirectories c# 
Csharp :: c# empty char 
Csharp :: c# debug console log 
Csharp :: how to make a button open window in wpf 
Csharp :: unity gameobject.findobjectswith tag set active 
Csharp :: xml node update attribute value c# 
Csharp :: get current directory cosmos 
Csharp :: .net loop through dictionary 
Csharp :: unity mesh showing Instance 
Csharp :: reference to another script unity 
Csharp :: generate a random number in c# 
Csharp :: asp textarea 
ADD CONTENT
Topic
Content
Source link
Name
4+2 =