Hi,
Do can I get the top two files from a folder? The folder can have any number of files.
I have the below query to sort them in descending order. After I do that I need to pick the top two records.
Directory.GetFiles(in_PDFFilesOutputFolder,“*”).OrderByDescending(Function(d) New FileInfo(d).LastModifiedDate).ToArray
arivu96
(Arivazhagan A)
March 4, 2022, 5:00pm
2
Hi @Krithi1 ,
Try below code Take(2) in the ending
Directory.GetFiles(in_PDFFilesOutputFolder,"*").OrderByDescending(Function(d) New FileInfo(d).LastModifiedDate).ToArray().Take(2)
Regards,
Arivu
Hi @arivu96
I see the below exception
I modified and trying this now- Directory.GetFiles(in_PDFFilesOutputFolder,“*”).OrderByDescending(Function(d) New FileInfo(d).LastModifiedDate).Take(2).ToArray
postwick
(Paul Ostwick)
March 4, 2022, 5:58pm
4
That’s because the code you typed in isn’t what arivu96 gave you. Look at it again.
Yes @postwick - that’s correct. Since that was not working for me, I modified the query as I pinged above and that worked
Thanks @arivu96 for the quick help. That helped me modify it a bit and try
system
(system)
Closed
March 7, 2022, 6:34pm
6
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.