List Files by Size

  • Thread starter Thread starter Jacques Oberto
  • Start date Start date
J

Jacques Oberto

Hi All,

I am looking for the easiest way to list all the files
in a directory by decreasing filesize.
Thanks,

Jacques
 
Jacques Oberto said:
I am looking for the easiest way to list all the files
in a directory by decreasing filesize.

Using a LINQ query in C# 3.0:

DirectoryInfo di = new DirectoryInfo(path);
var q = from f in di.GetFiles() orderby f.Length descending select
f.Name;
foreach (string f in q) Console.WriteLine(f);
 
"Alberto Poblacion" a écrit
Using a LINQ query in C# 3.0:

DirectoryInfo di = new DirectoryInfo(path);
var q = from f in di.GetFiles() orderby f.Length descending select
f.Name;
foreach (string f in q) Console.WriteLine(f);


Thanks Alberto: this linq thing seems very powerful!

Jacques
 
Back
Top