文件创建时间比较 /// <summary> /// 文件创建时间比较 /// </summary> public class FileComparer : IComparer { int IComparer.Compare(object Obj1, object Obj2) { FileInfo Fi1 = Obj1 as FileInfo; FileInfo Fi2 = Obj2 as FileInfo; return Fi1.CreationTime.CompareTo(Fi2.CreationTime); } }
调用实例
DirectoryInfo DirCollege = new DirectoryInfo(PublicInfo.ZipUploadFilePath);
FileInfo[] Fis = DirCollege.GetFiles(); Array.Sort(Fis,
new FileComparer());
注:需引用“using System.Collections;”命名空间