How to get the first 4 files in a directory

Hi @Henson_Ibon … Please try the below code…

StrArrFirstFour = Directory.GetFiles("YourFolderPath").OrderByDescending(Function(d) New FileInfo(d).LastWriteTime).take(4).ToArray

Here StrArrFirstFour is StringArray

Hope this helps…

1 Like