How to get latest file in folder using uipath

Hi All,

I need to get latest text file from folder how to do that please some one help me

Regards,
Hima

9 Likes

@thima,

Try with this,

new DirectoryInfo("yourDirectoryPath").GetFiles().OrderByDescending(Function(f) f.LastWriteTime).First().ToString

This will return the latest file name as a string output

1 Like

Its giving me first file but i want latest one

this expression would get you the latest file
str_filepath = Directory.GetFiles(yourfolder_path,“*.txt”).OrderByDescending(Function(d) New FileInfo(d).CreationTime).Tolist(0)

Cheers @thima

24 Likes

Which query you are referring here?

Is this the one?

new DirectoryInfo("yourDirectoryPath").GetFiles().OrderByDescending(Function(f) f.LastWriteTime).First().ToString
2 Likes

Hey

Here is a detailed article on that :slight_smile:

4 Likes

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