Hi,
Cable wrote:
Hi,
I've got a simple:
DirectoryInfo[] dis = d.GetDirectories();
foreach (DirectoryInfo di in dis)
The trouble is I can't find a way to sort or order the directoryinfo[]
array, I've found a way of doing it for files, but for some reason you
can't do the same to directoryinfo.
could some one give me some pointers.
thx
Chris
Any array can be sorted using the Array.Sort method.
http://msdn2.microsoft.com/en-us/lib...rray.sort.aspx
For example, you can use the Sort( Array, IComparer ) override.
http://msdn2.microsoft.com/en-us/library/aw9s5t8f.aspx
This lets you specify a class implementing the IComparer interface, in
which any criterium can be used for the sorting algorithm.
In .NET 2.0, a nice alternative is the generic version:
http://msdn2.microsoft.com/en-us/library/cxt053xf.aspx
In this override, the comparison algorithm is not defined in a class,
but in a method which is passed as a delegate to the Sort method.
HTH,
Laurent
--
Laurent Bugnion [MVP ASP.NET]
Software engineering:
http://www.galasoft-LB.ch
PhotoAlbum:
http://www.galasoft-LB.ch/pictures
Support children in Calcutta:
http://www.calcutta-espoir.ch