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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top