Get not last folder or file in folder

I try but it wont work:

Directory.GetFiles(directory,"*",SearchOption.AllDirectories).OrderByDescending(Function(d) New FileInfo(d).CreationTime).Take(2).Tolist(0)

im trying to get not last but before last file or folder in diretory. How i know with this - take(), we set witch file to get, but its not working for me, maybe i do something wrong, i always get the last file… Any ideas how easy to get not last but before last file or folder in folder?

Hi,

Can you try Skip(1) instead of Take(2) ?

Regards,

1 Like

it works thanks!

1 Like

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