I save the Last Run Date Time in sql server and retrieve the datetime value everytime for a new trigger.
I need to get the files from the source location only if the filename timestamp is greater than Last run date time.
LastRunDateTime = “20220313”
The file name will be as follows:
I need to compare only the date from Filename with LastRunDateTime, and only if the filename date is greater than LastRunDatetime. Then I have to Copy all those files to another location.
If DateTime.ParseExact(“LastRunDate”,“yyyyMMdd”,CultureInfo.InvariantCulture) > DateTime.ParseExact(Regex.Match(Path.GetFileNameWithoutExtension(CurrentFile.ToString),“(?<=_)\d+(?=_)”).ToString,“yyyyMMdd”,CultureInfo.InvariantCulture)
True-> Copy file Source will be CurrentFile.Tostring
The source folder has lots of other files, Hence I’m only filtering for specific filename and then I have to only copy the files which are greater than lastrundate from source folder to inputFolder.
For each file in Folder does not work for my usecase.
Search for For each file in folder and drag them in
If and give the condition I mentioned above
DateTime.ParseExact(LastRunDate,“yyyyMMdd”,CultureInfo.InvariantCulture) > DateTime.ParseExact(Regex.Match(Path.GetFileNameWithoutExtension(CurrentFile.ToString),“(?<=)\d+(?=)”).ToString,“yyyyMMdd”,CultureInfo.InvariantCulture)
@Sudharsan_Ka , I have found the solution myself. Thank you so much for your effort.
my solution is as follows:
Taking assign Getfiles=directory.getfiles(FolderPath,“Auth_released*.txt”)
second assign lastdate = “20220313”
taking for each and assigning Getfiles as input
Inside Foreach dragging IF Activity and passing the below expression
DateTime.ParseExact(System.Text.RegularExpressions.Regex.Match(System.IO.Path.GetFileNameWithoutExtension(item),“\d{8}_\d{4}$”).Value,“yyyyMMdd_HHmm”,System.Globalization.CultureInfo.InvariantCulture) >date.ParseExact(lastdate.ToString,“yyyyMMdd”,System.Globalization.CultureInfo.InvariantCulture)
So this way my issue got resolved.