Permalink
Browse files

added try-catch block and removed check if in debug mode for system r…

…estore point creation in privacy cleaner
  • Loading branch information...
little-apps committed Feb 21, 2015
1 parent 76189cf commit b4d1e017db478c759a8840bb796b02633a94e359
Showing with 23 additions and 10 deletions.
  1. +0 −1 Little System Cleaner/Main.xaml.cs
  2. +23 −9 Little System Cleaner/Privacy Cleaner/Controls/Results.xaml.cs
@@ -76,7 +76,6 @@ public Main()
this.InitializeComponent();

//this.Title = string.Format("Little Registry Cleaner v{0}", System.Windows.Forms.Application.ProductVersion);

}

void timerCheck_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
@@ -24,6 +24,7 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.IO;
using System.Linq;
using System.Text;
@@ -87,7 +88,7 @@ private void listView_MouseDoubleClick(object sender, MouseButtonEventArgs e)

private void buttonClean_Click(object sender, RoutedEventArgs e)
{
long seqNum = 0;
long lSeqNum = 0;

if (MessageBox.Show(App.Current.MainWindow, "Are you sure?", Utils.ProductName, MessageBoxButton.YesNo, MessageBoxImage.Question) != MessageBoxResult.Yes)
return;
@@ -96,11 +97,16 @@ private void buttonClean_Click(object sender, RoutedEventArgs e)

Report report = Report.CreateReport(Properties.Settings.Default.privacyCleanerLog);

#if (!DEBUG)
// Create system restore point
if (Properties.Settings.Default.optionsSysRestore)
SysRestore.StartRestore("Before Little Privacy Cleaner Fix", out seqNum);
#endif
try
{
SysRestore.StartRestore("Before Little System Cleaner (Privacy Cleaner) Cleaning", out lSeqNum);
}
catch (Win32Exception ex)
{
string message = string.Format("Unable to create system restore point.\nThe following error occurred: {0}", ex.Message);
MessageBox.Show(App.Current.MainWindow, message, Utils.ProductName, MessageBoxButton.OK, MessageBoxImage.Error);
}

foreach (ResultNode parent in (this._tree.Model as ResultModel).Root.Children)
{
@@ -120,10 +126,18 @@ private void buttonClean_Click(object sender, RoutedEventArgs e)
report.WriteLine("Successfully Cleaned Disk @ " + DateTime.Now.ToLongTimeString());
report.DisplayLogFile(Properties.Settings.Default.privacyCleanerDisplayLog);

#if (!DEBUG)
// End restore point
SysRestore.EndRestore(seqNum);
#endif
if (lSeqNum != 0)
{
try
{
SysRestore.EndRestore(lSeqNum);
}
catch (Win32Exception ex)
{
string message = string.Format("Unable to create system restore point.\nThe following error occurred: {0}", ex.Message);
MessageBox.Show(App.Current.MainWindow, message, Utils.ProductName, MessageBoxButton.OK, MessageBoxImage.Error);
}
}

MessageBox.Show(App.Current.MainWindow, "Successfully Cleaned Disk", Utils.ProductName, MessageBoxButton.OK, MessageBoxImage.Information);

0 comments on commit b4d1e01

Please sign in to comment.