Gate name folder by last modified

i have a folder, how can i get the folder name of last modified folder?

Hi @samarasenja

can you give a try with the following?

(From f In New DirectoryInfo("yourFolderPath").GetDirectories()
Order By f.LastWriteTime Descending
Select f.Name).First()

Regards!

can u tell me this flow

HI @samarasenja

To get the name of the folder based on last modified in UiPath, you can use the following code snippet

Directory.GetFiles("Your Folder Path").Select(Function(f) New FileInfo(f)).OrderByDescending(Function(fi) fi.LastWriteTime).First()

This will return the name of the folder that contains the file that was last modified

Regards
Gokul

you can assign it to a string variable, it will return the name of your folder

image

if you want to return the full path, then make this simple change

(From f In New DirectoryInfo("YourFolderPath").GetDirectories()
Order By f.LastWriteTime Descending
Select f.FullName).First()

Regards!

Thanks This Is solved

1 Like

Hello @samarasenja , You can use the split function.
suppose variable var have the path . Create one more variable which will have folder name

str_var=Split(var_string,"").Last

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.