Home > Net >  In UiPath, using Invoke code activity I am trying to get files in a folder which are updated or modi
In UiPath, using Invoke code activity I am trying to get files in a folder which are updated or modi

Time:10-13

These are the codes that I have tried

Dim myDirectory As new.IO.DirectoryInfo("C:\MyFolder") 

Dim myFiles() As String = myDirectory.GetFiles.OrderByDescending(Function(x) x.LastWriteTime).Select(Function(x) x.FullName).Take(40).ToArray

MsgBox(String.Join(Environment.NewLine, myFiles)

Here since I am giving Take(40), it will be taking only last 40files, but I want which can take all files which are modifies in last 24hrs(it may be 100 or 1000)

CodePudding user response:

If you want to find all the files that were modified in the last 24 hours you can use a StudioX activity to loop through each file and then use the LastModifiedDate method to find the data they were modified.

First, you will need to click Show StudioX activities in the Activities window filter.

enter image description here

Then, select the For Each File in Folder activity.

enter image description here

After that, use this formula in the If activity: Convert.ToDateTime(CurrentFile.LastModifiedDate()) > Now.AddDays(-1)

enter image description here

In this example, the name of any file that was modified in the last 24 hours will show up in a message box.

  • Related