Hello everyone,
I save an Excel file in a folder every day. Now I want all files in the folder to be deleted whose created date is more than 14 days.
I would appreciate your help.
BR
Chetan
Hello everyone,
I save an Excel file in a folder every day. Now I want all files in the folder to be deleted whose created date is more than 14 days.
I would appreciate your help.
BR
Chetan
Hi @Chetan_Wagh ,
You can get file after 14 days by date created
if you need get all file date is more than 14 days.
file.CreationTime.Date.ToString < DateTime.Today.AddDays(-14).ToString
hope it help,
this will give you all files older than 14…use a for loop and delete file inside it
System.IO.Directory.GetFiles("Folder",".xls*").Where(function(x) Cdate(New FileInfo(x).CreatedDate)<=Now.AddDays(-14))
cheers
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.