How to get the latest file in a folder


#1

Hi People,

I am trying to get the latest file in a directory… i declared a variable and assigned it to a folder as below:
folderName = new DirectoryInfo("\Mac\Home\Documents\UiPath\folderpath")
The folderName is stored as system.io.DirectoryInfo.
I also declared and assigned a filename = folderName…GetFiles().OrderByDescending(f => f.LastWriteTime).First() . The filename is stored as system.io.File but i am still getting the error “compiler error encountered processing expression”

What could i be doing wrong?
Thank you


#2

Hi @Olaoluwa,

Refer this post

Regards,
Arivu