How to get modified files within a folder


I have implemnented a scenaio to get last modified files from current date in folder so BOT runs daily at 6 PM which considers changerun of 18 hrs and in this case any changes performed after the scheduled time are not recorded. So, now it was asked to also get remaining 6 hours which is missing from previous date to be added to next scheduled time run. Can anyone please help on this

Currently I’m using,
GetDirectoryInfo = New DirectoryInfo(Userfolderpath) —> Type is System.IO.DirectoryInfo
GetFileInfo = GetDirectoryInfo.getfiles(“.”) —> Type is System.IO.FileInfo
GetTodayFilesInfo = GetFileInfo.where(Function(x) x.LastModifiedDate.ToString.Contains(Now.ToSting(“MM/dd/yyyy”))).Toarray
—> Type is System.IO.FileInfo


Hi @koneruupendra111

Try this

Assign → CurrentDateTime = DateTime.Now
Assign → PreviousDayEnd = CurrentDateTime.Date.AddHours(6)  ' Setting the end time of the previous day at 6 AM

GetDirectoryInfo = New DirectoryInfo(Userfolderpath)
GetFileInfo = GetDirectoryInfo.GetFiles("."c)
GetTodayFilesInfo = GetFileInfo.Where(Function(x) x.LastWriteTime >= PreviousDayEnd AndAlso x.LastWriteTime <= CurrentDateTime).ToArray()


Hi @lrtetala,

Let me rephrase the scenario, to get the files in the folder based on modified date change happened within 24 hours (includes Current date time and previous date time) and then modified file is sent over mail. So here the bot is scheduled at 6PM everyday and accordingly files should be sent without overlapping with already sent previous files.

However, BOT schedule time might vary due to other dependencies.
I tried some other ways but it’s not working.