Need help on vb code to get the latest file from folder

Hi all,

I am new to UiPath Studio X. So I tried to use the following code to get the latest file from a folder.

System.IO.Directory.GetFiles(<[str_FolderPath]>,“.”,SearchOption.AllDirectories).OrderByDescending(Function(d) New FileInfo(d).CreationTime.ToList(0)

However, when I tried to run the activities, it only showed the code instead of the actual file name.

Any help is appreciated.

TWW

Hi @tww

Click on Open in expression editor and give your expression in that

System.IO.Directory.GetFiles(Str_FolderPath, ".", SearchOption.AllDirectories).OrderByDescending(Function(d) New FileInfo(d).CreationTime).First()

Regards,

1 Like

@tww

What is the type of ienum_latestfile

Also looks like it is string type and you would have given it as string

Just open advanced editor and paste the formula properly

Cheers

1 Like

Thank you for your help

1 Like

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