Open the oldest pdf


#1

Hello,

How do I open the oldest pdf in a folder and get its name?


#2

You can search for the properties of files and use that to determine which is the oldest…

Use something like the following https://msdn.microsoft.com/en-us/library/system.io.file.getcreationtime(v=vs.110).aspx


#3

Hey @mario

You can try this:

`

FileSystemInfo fileInfo = new DirectoryInfo(directoryPath).GetFileSystemInfos().OrderByDescending(function(fi) fi.CreationTime).First()

Regards…!!
AKsh
`


#4

Thanks guys. FileSystemInfo fileInfo is my left side in action assign? So can I rename it for example to FileName? What kind of variable should be that?


#5

Yes create a variable with name “fileinfo” with a data type System.IO.FileSystemInfo then assign the above thing and replace directory path with your directory path.


#6

thanks a lot