Require the code/ logic to delete all folders from a directory where the creation date is older than 5 days
Hello
You can use an For Each folder (FileInfo) and check on directory.CreationTime.
If it is older than 5 days, then delete the folder.
For each folder.xaml (8.0 KB)
Regards
Soren
Use this LINQ to get all folders older than 5 days.
Directory.GetDirectories("C:\Users\ashok\Downloads", "*", SearchOption.AllDirectories).
Where(Function(d) Directory.GetCreationTime(d) < DateTime.Now.AddDays(-5)).ToArray()
This will return you array of string
Now iterate all folders and delete one by one.
This is the optimal way to do this as it will avoid unwanted iteration to folders > 5 days of creation time.
Sample xaml here.
Workflow.xaml (8.9 KB)
Thanks,
Ashok