Get TOP 10 Files from directory

  • Thread starter Thread starter Priya Bange
  • Start date Start date
P

Priya Bange

Guest
Hi Experts,

I have the below method that reads all the files available in the directory. I am looking forward to read just top 10 oldest files available in the directory path & execute the foreach loop. Please help with modification of this method.


public void ProcessExistingFiles(string inputDirectory)
{

foreach (var filePath in Directory.EnumerateFiles(inputDirectory, "*.*", SearchOption.AllDirectories))
{
Console.WriteLine($"Get TOP 10 oldest files in directory path {filePath}");

}
}


Thanks
Priya

Continue reading...
 
Back
Top