Sorting FileInfo[] by Date

  • Thread starter Thread starter Filippo Pandiani
  • Start date Start date
F

Filippo Pandiani

Hi there,
I have just populated my FileInfo[] array with files from a folder.
Before I display them on a grid, I would like to sort them by Date DESC.

What is the easiest way to do so?

Filippo.
 
Never used ICompare before, do you have a sample I can use as start up?

Filippo.


cs said:
make a class that implements IComparer


Filippo Pandiani said:
Hi there,
I have just populated my FileInfo[] array with files from a folder.
Before I display them on a grid, I would like to sort them by Date DESC.

What is the easiest way to do so?

Filippo.
 
Just found a sample.
http://aspnet.4guysfromrolla.com/articles/060403-1.aspx


Thanks
F.


Filippo Pandiani said:
Never used ICompare before, do you have a sample I can use as start up?

Filippo.


cs said:
make a class that implements IComparer


Filippo Pandiani said:
Hi there,
I have just populated my FileInfo[] array with files from a folder.
Before I display them on a grid, I would like to sort them by Date DESC.

What is the easiest way to do so?

Filippo.
 
Probably the easiest and quickest way is to create a custom IComparer
implementation which compares the dates of the FileInfos, and then pass
this to the oveload of the Array.Sort() method that takes an IComparer.

Greg

This posting is provided "AS IS" with no warranties, and confers no rights.
 
Back
Top