30 days old files and email files in the folder will delete

Hi Team,
I want to Create a process
if file date more than 30 days from current date want to delete from the folder


i tried but i am not able to do

Thanks

Check this solution in case the files have date in their names How to delete old File - #4 by ptrobot

oldFilesToDelete = (From f In Directory.GetFiles("C:\Temp\old")
Let strDate = System.Text.RegularExpressions.Regex.Match(Path.GetFileName(f), "\d{2}\.\d{2}\.\d{4}").ToString
Where Not String.IsNullOrWhiteSpace(strDate) AndAlso DateTime.ParseExact(strDate, "dd.MM.yyyy",system.Globalization.CultureInfo.InvariantCulture) < Today.AddDays(-30)
Select f
).ToArray

oldFilesToDelete is an array of strings.

The result is a list of files (with full paths) that you can loop through and delete. Files without a date in their name will be ignored.


The following workflow will delete files which is written 30 days ago in a specific folder from worksheet Bot to delete old files - #2 by Yoichi

Hi @Yogeshwar_Singh,

What about this

Directory.GetFiles("D:\Projects\STS\Input").ToList().Where(Function (x) CDate(New FileInfo(x).CreatedDate)<Now.AddDays(-30)).ToArray()

Workflow

Thanks,