C# list top 20 biggest files via given path
static void ListTop20BiggestFile() { string str = @"D:\C"; var files = Directory.GetFiles(str, "*", SearchOption.AllDirectories).OrderByDescending(x => (new FileInfo(x)).Length).Take(20).ToList(); if(files!=null && files.Any()) { foreach(var file in files) { Console.WriteLine(file); } } }