diff --git a/SteamCleaner/App.xaml.cs b/SteamCleaner/App.xaml.cs
index 9bd6c79..66becf0 100644
--- a/SteamCleaner/App.xaml.cs
+++ b/SteamCleaner/App.xaml.cs
@@ -1,5 +1,6 @@
#region
+using System.Diagnostics;
using System.Windows;
using SteamCleaner.Utilities;
@@ -14,6 +15,9 @@ public partial class App : Application
{
private void AppStartup(object sender, StartupEventArgs args)
{
+ if (!Debugger.IsAttached)
+ ExceptionHandler.AddGlobalHandlers();
+
var mainWindow = new MainWindow
{
DataContext = new MainWindowViewModel()
diff --git a/SteamCleaner/SteamCleaner.csproj b/SteamCleaner/SteamCleaner.csproj
index 0066362..4e9f7c1 100644
--- a/SteamCleaner/SteamCleaner.csproj
+++ b/SteamCleaner/SteamCleaner.csproj
@@ -118,6 +118,7 @@
+
diff --git a/SteamCleaner/Utilities/CleanerUtilities.cs b/SteamCleaner/Utilities/CleanerUtilities.cs
index 2f04cc0..c4c9e30 100644
--- a/SteamCleaner/Utilities/CleanerUtilities.cs
+++ b/SteamCleaner/Utilities/CleanerUtilities.cs
@@ -50,7 +50,7 @@ private static List DetectRenPyRedistributables(string sDir)
files.AddRange(DetectRenPyRedistributables(d));
foreach (var filter in filters.Where(filter => d.ToLower().Contains(filter)))
{
- files.AddRange(from f in Directory.GetFiles(d) select f);
+ files.AddRange(Directory.GetFiles(d).Select(f => f));
}
}
return files;
diff --git a/SteamCleaner/Utilities/ExceptionHandler.cs b/SteamCleaner/Utilities/ExceptionHandler.cs
new file mode 100644
index 0000000..f63fb30
--- /dev/null
+++ b/SteamCleaner/Utilities/ExceptionHandler.cs
@@ -0,0 +1,39 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Newtonsoft.Json;
+
+namespace SteamCleaner.Utilities
+{
+ public static class ExceptionHandler
+ {
+ private static readonly string LogsPath = Path.Combine("", "Logs");
+
+ public static void AddGlobalHandlers()
+ {
+ AppDomain.CurrentDomain.UnhandledException += (sender, args) =>
+ {
+ try
+ {
+ if (!Directory.Exists(LogsPath))
+ Directory.CreateDirectory(LogsPath);
+
+ var filePath = Path.Combine(LogsPath,
+ $"UnhandledException_{DateTime.Now.ToShortDateString().Replace("/", "-")}.json");
+
+ File.AppendAllText(filePath,
+ JsonConvert.SerializeObject(args.ExceptionObject, Formatting.Indented) + "\r\n\r\n");
+
+ Console.WriteLine("An Unhandled Exception was Caught and Logged to:\r\n{0}", filePath);
+ }
+ catch
+ {
+ // ignored
+ }
+ };
+ }
+ }
+}
\ No newline at end of file
diff --git a/version.xml b/version.xml
index 02c6011..9f008b8 100644
--- a/version.xml
+++ b/version.xml
@@ -1,5 +1,5 @@
- 1.7
+ 1.8
https://github.com/Codeusa/SteamCleaner/releases/latest