How to search latest folder created for any files

Hi all,

I would like to know how I can search the latest created folder for files. I want check if any pdf files exist in that folder before proceed with my process. The latest created folder could be days or months ago, there is no fixed creation time.

@anonymous3 - You can try like this…

StrRecentFolder = Directory.GetDirectories("YourFolderPath").OrderByDescending(Function(d) New FileInfo(d).CreationTime)(0)

Here StrFolder is String Variable…

My Folders

My output


With this result…then you can write IF statement as directory.getfiles(StrRecentFolder,"*.pdf).count >= 1 and continue the process.

1 Like

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