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); }
private void buttonRestore_Click(object sender, EventArgs e) { long lSeqNum = 0; if (this.listViewFiles.SelectedIndices.Count > 0 && this.listViewFiles.Items.Count > 0) { string strFile = this.listViewFiles.SelectedItems[0].Text; string strFilePath = string.Format("{0}\\{1}", Properties.Settings.Default.strOptionsBackupDir, strFile); if (!File.Exists(strFilePath)) { MessageBox.Show(this, Properties.Resources.restoreFileNotFound, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error); // Remove from list this.listViewFiles.Items[this.listViewFiles.SelectedItems[0].Index].Remove(); // Clear selection this.listViewFiles.SelectedItems.Clear(); return; } if (MessageBox.Show(this, Properties.Resources.restoreAsk, Application.ProductName, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { SysRestore.StartRestore("Before Little Registry Cleaner Restore", out lSeqNum); if (xmlReg.loadAsXml(xmlReader, strFilePath)) { MessageBox.Show(this, Properties.Resources.restoreRestored, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Information); if (Properties.Settings.Default.bOptionsDelBackup) { File.Delete(strFilePath); this.listViewFiles.SelectedItems[0].Remove(); } } else { MessageBox.Show(this, Properties.Resources.restoreError, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error); } SysRestore.EndRestore(lSeqNum); } } }