How to get all the files of a directory in creation time order in string array


Please help on this

Thanks in advance :slight_smile:

You can use the assign activity and use the expression Directory.GetFiles(@"D:\UiPath")
The expression returns a list of files in the given directory.

Use this for directory path : Directory.GetFiles(“Directory Path”)
For getting the file creation time : File.GetCreationTime(item.ToString).ToString

Add them into a List and the sort the list accordingly.
For reference : Main.xaml (9.3 KB)


Hi @SwarnaGold

String[] = Directory.GetFiles(“FolderPath”,“FileType”,SearchOption.AllDirectories).OrderByDescending(Function(d) New FileInfo(d).CreationTime)

Use this Expression to get the all the files based on descending order
Hope this will helpful

JothyPrasanth M


Thanks I got solution

Hi Karthik,

I want to get all file names from a folder. but getting only first file name. plz help.

Hope following link will help

Directory.GetFiles(“Path”).OrderByDescending(Function(d) New FileInfo(d).LastWriteTime)

Path.GetFileName( FileNames(0) )

Thanks Man!! You solved my the problem!!