protected virtual void CreateRollingBackup() { var timeStamp = $"{DateTime.Now:yyyyMMdd-HHmmss-ffff}"; var normalBackup = new FileDataProviderWithBackup(FilePath + BackupFileSuffix); var normalBackupWithoutSuffix = normalBackup.FilePath.Replace(BackupFileSuffix, ""); try { normalBackup.MoveTo(normalBackupWithoutSuffix + timeStamp + BackupFileSuffix); } catch (Exception ex) { Runtime.MessageCollector.AddExceptionStackTrace($"Failed to create rolling backup of file {FilePath}", ex); throw; } }
private void SaveToXml() { try { var factory = new CryptographyProviderFactory(); var cryptographyProvider = factory.CreateAeadCryptographyProvider(mRemoteNG.Settings.Default.EncryptionEngine, mRemoteNG.Settings.Default.EncryptionBlockCipherMode); cryptographyProvider.KeyDerivationIterations = mRemoteNG.Settings.Default.EncryptionKeyDerivationIterations; var xmlConnectionsSerializer = new XmlConnectionsSerializer(cryptographyProvider) { Export = Export, SaveFilter = SaveFilter, UseFullEncryption = mRemoteNG.Settings.Default.EncryptCompleteConnectionsFile }; var xml = xmlConnectionsSerializer.Serialize(ConnectionTreeModel); var fileDataProvider = new FileDataProviderWithBackup(ConnectionFileName); fileDataProvider.Save(xml); } catch (Exception ex) { Runtime.MessageCollector.AddExceptionStackTrace("SaveToXml failed", ex); } }