I want to delete the excel files from a folder which contains more than 4days old
for example I should keep the excel till 28-4=24/09/2022, before 24/09/2022 excel I need to delete.
the excels contains inside the folder :
“\10.1.2.82\Software Data\Automation\NaveenKumarS\ModmedInventory\ModmedRejection28092022”.
Loop each excel files from folder
Directory.GetFiles(“\10.1.2.82\Software Data\Automation\NaveenKumarS\ModmedInventory\ModmedRejection28092022”,“*.xlsx”)
in if condition (Directory.GetCreationTime(item.ToString).ToShortDateString.CompareTo(now.date.AddDays(-4).ToShortDateString))=-1
mention the folder path which contains ModmedRejection24092022 and more folders
Assign Days=2 , because of filter last 2 days and days should Integer
Use assign and separate the date from the folder by
FolderDateString=System.Text.RegularExpressions.Regex.Match(CurrentFolder.Name,"\d+").ToString.Trim
FolderdateString was the variable type of string
Convert it to date format
FolderDate=DateTime.ParseExact(FolderDateString,"ddMMyyyy",System.Globalization.CultureInfo.InvariantCulture)
where folderDate was variable type of System.DateTime