Portable Tool for an Ideal Windows Setup
C# activatorbloatware-removalcsharpdebloatdebloaterdisable-servicesmonitoring-systemportableprivacy-toolsregistry-tweakssystem-tuningsystem-utilitytelemetrytweakerwindows-10windows-11windows-debloatwindows-defenderwindows-optimizationwindows-tweaks
fixed error when opening the log
Greedeks2ce62f46a21a
diff --git a/.Source/GTweak/Utilities/Controls/ErrorLogging.cs b/.Source/GTweak/Utilities/Controls/ErrorLogging.csindex 554242fe..04f4e507 100644--- a/.Source/GTweak/Utilities/Controls/ErrorLogging.cs+++ b/.Source/GTweak/Utilities/Controls/ErrorLogging.cs@@ -1,4 +1,5 @@-using System;+using GTweak.Utilities.Helpers;+using System;using System.Diagnostics;using System.IO;using System.Runtime.CompilerServices;@@ -14,6 +15,23 @@ namespace GTweak.Utilities.Controlsinternal static void LogWritingFile(Exception ex, [CallerMemberName] string memberName = "") => Task.Run(() => LogToFile(ex, memberName)).Wait();+ private static async Task EnsureAssociation()+ {+ try+ {+ string assocLogFile = await CommandExecutor.GetCommandOutput("/c assoc .log", false);++ if (assocLogFile.IndexOf("=", StringComparison.OrdinalIgnoreCase) < 0)+ {+ string assocTxtFile = await CommandExecutor.GetCommandOutput("/c assoc .txt", false);++ if (assocTxtFile.IndexOf("=", StringComparison.OrdinalIgnoreCase) >= 0)+ CommandExecutor.RunCommand($"/c assoc .log={assocTxtFile.Split('=')[1].Trim()}");+ }+ }+ catch (Exception fileEx) { LogDebug(fileEx); }+ }+private static async Task LogToFile(Exception ex, string memberName){try@@ -22,11 +40,19 @@ namespace GTweak.Utilities.Controlsusing var writer = new StreamWriter(stream, new UTF8Encoding(false));await writer.WriteLineAsync($"[{DateTime.Now}]\nMember: {memberName}\nError: {ex.Message}\nStack Trace:\n{ex.StackTrace}\n");await writer.FlushAsync();- Process.Start(new ProcessStartInfo++ await EnsureAssociation();++ if (File.Exists(StoragePaths.LogFile)){- FileName = StoragePaths.LogFile,- UseShellExecute = true- });+ Process.Start(new ProcessStartInfo+ {+ FileName = StoragePaths.LogFile,+ UseShellExecute = true+ });+ }+ else+ LogDebug(new FileNotFoundException(StoragePaths.LogFile));}catch (Exception fileEx) { LogDebug(fileEx); }}