Many times we came across a scenario where the folder contains bulk of files but business require the last modified created file.
In this article , we will see how we can achieve this in UiPath.
Implementation in UiPath*****
Step 1:- Drag an assign activity in the designer panel and pass the drive location.
Step 2:- Drag a message box and pass the function to get the required result
Lets understand the above function.
Firstly we have used Directory.GetFiles function which has the following parameters.
Path - Directory location .
SearchPattern-* (It would include all the files inside the folder)
SearchOption.AllDirectories- It would look all directory and sub directories.
Then we will further sort the files in descending order by creation time and pick the first file from the directory by using the function Take(1)
I hope you enjoyed the article!
Happy automation!!