Select folder1

Hi Anyone can tell me, i want to select recent date & time folder from folder. how i do it? there are multiple folders.

Hi @yogitagaikwad2206

Can you try the below syntax:

recentFolder = Directory.GetDirectories("C:\YourFolderPath").
    OrderByDescending(Function(folder) DateTime.ParseExact(Path.GetFileName(folder), "yyyyMMdd_HHmmss", System.Globalization.CultureInfo.InvariantCulture)).
    FirstOrDefault()

Hope it helps!!

@yogitagaikwad2206

for each folder in folder …you have sort by date time in it

the first one would be latest

cheers

For completeness, I would add a “Break” activity at the end of the “Do” block to stop looping after the first iteration.

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