static string OldestOf(string one, string two) { ReportInfo a = new ReportInfo(one); ReportInfo b = new ReportInfo(two); if (a.Date < b.Date) return one; else return two; }
// Maybe change this to where you can specify the timespan. public virtual void ArchiveOldLogs() { string[] files = Directory.GetFiles(logFilePath, "*.txt", System.IO.SearchOption.TopDirectoryOnly); List<FileInfo> moveList = new List<FileInfo>(); for (int i = 0; i < files.Length; i++) { ReportInfo current = new ReportInfo(files[i]); if(DateTime.Now - current.Date > new TimeSpan(24, 0, 0)) moveList.Add(new FileInfo(files[i])); } ArchiveFiles(logFilePath, moveList); }
static string RegionAndItem(string fullpath) { ReportInfo info = new ReportInfo(fullpath); return info.Region + " - " + info.ItemName; }
public static int CompareByDate(ReportInfo a, ReportInfo b) { return DateTime.Compare(a.date, b.date); }