C# (C Sharp) - How to sort files by their creation date?
using System; using System.Collections; using System.IO; namespace InfoSystem { /// <summary> /// This class is created by Anton Zamov /// For more information about Anton Zamov /// and a lot of other useful examples /// please visit http://zamov.online.fr /// You may use and redistribute this code as /// long as you keep this message intact. /// </summary> public class FilesDateComparer: IComparer { public int Compare (object x, object y) { int iResult; FileInfo oFileX=(FileInfo)x; FileInfo oFileY=(FileInfo)y; if(oFileX.LastWriteTime==oFileY.LastWriteTime) { iResult=0; } else if(oFileX.LastWriteTime>oFileY.LastWriteTime) { iResult=1; } else { iResult=-1; } return iResult; } } }
Category: | C# (C Sharp) |
<< Go back