public override void Backup(string backupDirectory) { using (var key = OpenRegKey()) { switch (key.GetValueKind(ValueName)) { case RegistryValueKind.ExpandString: case RegistryValueKind.String: var targetValue = key.GetStringSafe(ValueName); var dir = CreateBackupDirectory(backupDirectory); var fileName = PathTools.SanitizeFileName(string.Concat(FullRegKeyPath, " - ", ValueName) .TrimStart('\\').Replace('.', '_')) + ".reg"; RegistryTools.ExportRegistryStringValues(Path.Combine(dir, fileName), FullRegKeyPath, new KeyValuePair <string, string>(ValueName, targetValue)); break; case RegistryValueKind.MultiString: case RegistryValueKind.Binary: case RegistryValueKind.DWord: case RegistryValueKind.QWord: case RegistryValueKind.Unknown: Debug.Fail("Unsupported type " + ValueName); break; } } }
public override void Backup(string backupDirectory) { using (var key = RegistryTools.OpenRegistryKey(ParentPath)) { var target = key.GetValue(Name); var targetValue = target as string; if (targetValue != null) { var dir = CreateBackupDirectory(backupDirectory); var fileName = PathTools.SanitizeFileName(FullName.TrimStart('\\').Replace('.', '_')) + ".reg"; RegistryTools.ExportRegistryStringValues(Path.Combine(dir, fileName), ParentPath, new KeyValuePair <string, string>(Name, targetValue)); } else { Debug.Fail("Unsupported type " + target.GetType().FullName); } } }