/// <summary> /// Deletes the old backup files. /// </summary> private void DeleteOldBackupFiles() { logHandler = new LogHandler(); int days = ConfigurationXmlHandler.GetDeleteBackupsOlderThanDays(); string backupLocation = ConfigurationXmlHandler.GetBackupLocation(); if (days > 0) { try { ProcessDeleteFiles(backupLocation, days + 1); //Add 1 to number of days, since it has to delete files older than the specified number of days logHandler.LogMessage(LogHandler.MessageType.INFO, string.Format("Cleaned up backup files older than {0} days", days)); } catch (Exception ex) { logHandler.LogMessage(LogHandler.MessageType.ERROR, string.Format("Error while cleaning up files older than {0} days: {1}", days, ex.ToString())); } } }
/** * Synchronise with the values from the Configuration file. */ private void SyncFromConfiguration() { this.backupLocation = ConfigurationXmlHandler.GetBackupLocation(); this.deleteBackupAfterDays = ConfigurationXmlHandler.GetDeleteBackupsOlderThanDays(); }
public void RetrieveDeleteBackupOlderThanDaysTest() { int days = ConfigurationXmlHandler.GetDeleteBackupsOlderThanDays(); Assert.AreEqual(7, days); }