public bool BackUpList(String location) { xmlWriter w = new xmlWriter(); xmlRegistry xmlReg = new xmlRegistry(); try { w.open(location); foreach (var strRegistrySection in BackUpKeys) { if (xmlRegistry.keyExists(strRegistrySection)) { xmlElement wroot = new xmlElement(xmlRegistry.XML_ROOT); wroot.write(w, 1, false, true); xmlReg.saveAsXml(w, false, strRegistrySection, ""); wroot.writeClosingTag(w, -1, false, true); } } } catch (Exception ex) { ErrorMessage = ex.Message; return(false); } finally { w.close(); } return(true); }
public bool RestoreBackUp(String location) { xmlReader xmlReader = new xmlReader(); xmlRegistry xmlReg = new xmlRegistry(); try { xmlReg.loadAsXml(xmlReader, location); } catch (Exception ex) { ErrorMessage = ex.Message; return(false); } return(true); }
/// <summary> /// If problems were found, removes them from registry /// </summary> private void FixProblems() { xmlRegistry xmlReg = new xmlRegistry(); long lSeqNum = 0; if (this.treeModel.Nodes.Count > 0) { if (!Properties.Settings.Default.bOptionsAutoRepair) { if (MessageBox.Show(this, Properties.Resources.mainProblemsFix, Application.ProductName, MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes) { return; } } // Send usage data to Little Software Stats Watcher.Event("Functions", "Fix Problems"); // Create Restore Point SysRestore.StartRestore("Before Little Registry Cleaner Registry Fix", out lSeqNum); // Generate filename to backup registry string strBackupFile = string.Format("{0}\\{1:yyyy}_{1:MM}_{1:dd}_{1:HH}{1:mm}{1:ss}.xml", Properties.Settings.Default.strOptionsBackupDir, DateTime.Now); BadRegKeyArray arrBadRegKeys = new BadRegKeyArray(); foreach (BadRegistryKey badRegKeyRoot in this.treeModel.Nodes) { foreach (BadRegistryKey badRegKey in badRegKeyRoot.Nodes) { if (badRegKey.Checked == CheckState.Checked) { arrBadRegKeys.Add(badRegKey); } } } // Generate a restore file and delete keys & values xmlReg.deleteAsXml(arrBadRegKeys, strBackupFile); SysRestore.EndRestore(lSeqNum); // Disable menu items this.fixToolStripMenuItem.Enabled = false; this.toolStripButtonFix.Enabled = false; // Clear status text ResourceManager rm = new ResourceManager(this.GetType()); this.toolStripStatusLabel1.Text = rm.GetString("toolStripStatusLabel1.Text"); this.toolStripStatusLabel1.Tag = "toolStripStatusLabel1.Text"; // Display message box if (!Properties.Settings.Default.bOptionsAutoExit) { MessageBox.Show(this, Properties.Resources.mainProblemsRemoved, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Information); } // Clear old results this.treeModel.Nodes.Clear(); // If power user option selected, Automatically exit program if (Properties.Settings.Default.bOptionsAutoExit) { this.bDisplayExitMsgBox = false; this.Close(); return; } // Scan again if (Properties.Settings.Default.bOptionsRescan) { ScanRegistry(); } } }