Display a notification when file is not found
MODIFY
WalletWasabi.Gui/Global.cs
WalletWasabi.Gui/Global.cs
@@ -626,7 +626,7 @@ namespace WalletWasabi.Gui
{
message = Guard.Correct(message);
title = Guard.Correct(title);
- NotificationHelpers.Notify(message, title, notificationType, () => IoHelpers.OpenFileInTextEditor(Logger.FilePath));
+ NotificationHelpers.Notify(message, title, notificationType, () => FileHelpers.OpenFileInTextEditor(Logger.FilePath));
Logger.LogInfo($"Transaction Notification ({notificationType}): {title} - {message} - {e.Transaction.GetHash()}");
}

ADD
WalletWasabi.Gui/Helpers/FileHelpers.cs
+using System;
+using System.Diagnostics;
+using System.IO;
+using System.Runtime.InteropServices;
+using WalletWasabi.Helpers;
+using WalletWasabi.Logging;
+
+namespace WalletWasabi.Gui.Helpers
+{
+ public static class FileHelpers
+ {
+ public static void OpenFileInTextEditor(string filePath)
+ {
+ if (File.Exists(filePath))
+ {
+ if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
+ {
+ // If no associated application/json MimeType is found xdg-open opens retrun error
+ // but it tries to open it anyway using the console editor (nano, vim, other..)
+ EnvironmentHelpers.ShellExec($"gedit {filePath} || xdg-open {filePath}", waitForExit: false);
+ }
+ else
+ {
+ if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
+ {
+ bool openWithNotepad = true; // If there is an exception with the registry read we use notepad.
+
+ try
+ {
+ openWithNotepad = !EnvironmentHelpers.IsFileTypeAssociated("json");
+ }
+ catch (Exception ex)
+ {
+ Logger.LogError(ex);
+ }
+
+ if (openWithNotepad)
+ {
+ // Open file using Notepad.
+ using Process process = Process.Start(new ProcessStartInfo
+ {
+ FileName = "notepad.exe",
+ Arguments = filePath,
+ CreateNoWindow = true,
+ UseShellExecute = false
+ });
+ return; // Opened with notepad, return.
+ }
+ }
+
+ // Open file wtih the default editor.
+ using (Process process = Process.Start(new ProcessStartInfo
+ {
+ FileName = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? filePath : "open",
+ Arguments = RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? $"-e {filePath}" : "",
+ CreateNoWindow = true,
+ UseShellExecute = RuntimeInformation.IsOSPlatform(OSPlatform.Windows)
+ }))
+ { }
+ }
+ }
+ else
+ {
+ NotificationHelpers.Error("File not found.");
+ }
+ }
+ }
+}
\ No newline at end of file

MODIFY
WalletWasabi.Gui/Shell/Commands/DiskCommands.cs
WalletWasabi.Gui/Shell/Commands/DiskCommands.cs
@@ -4,6 +4,7 @@ using System;
using System.Composition;
using System.IO;
using System.Reactive.Linq;
+using WalletWasabi.Gui.Helpers;
using WalletWasabi.Logging;
namespace WalletWasabi.Gui.Shell.Commands
@@ -69,17 +70,17 @@ namespace WalletWasabi.Gui.Shell.Commands
private void OnOpenLogFile()
{
- IoHelpers.OpenFileInTextEditor(Logger.FilePath);
+ FileHelpers.OpenFileInTextEditor(Logger.FilePath);
}
private void OnOpenTorLogFile()
{
- IoHelpers.OpenFileInTextEditor(Global.TorLogsFile);
+ FileHelpers.OpenFileInTextEditor(Global.TorLogsFile);
}
private void OnOpenConfigFile()
{
- IoHelpers.OpenFileInTextEditor(Global.Config.FilePath);
+ FileHelpers.OpenFileInTextEditor(Global.Config.FilePath);
}
[ExportCommandDefinition("File.Open.DataFolder")]

MODIFY
WalletWasabi.Gui/Tabs/SettingsViewModel.cs
WalletWasabi.Gui/Tabs/SettingsViewModel.cs
@@ -374,7 +374,7 @@ namespace WalletWasabi.Gui.Tabs
private void OpenConfigFile()
{
- IoHelpers.OpenFileInTextEditor(Global.Config.FilePath);
+ FileHelpers.OpenFileInTextEditor(Global.Config.FilePath);
}
#region Validation

MODIFY
WalletWasabi/Helpers/IoHelpers.cs
WalletWasabi/Helpers/IoHelpers.cs
@@ -144,58 +144,6 @@ namespace System.IO
}
}
- public static void OpenFileInTextEditor(string filePath)
- {
- if (File.Exists(filePath))
- {
- if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
- {
- // If no associated application/json MimeType is found xdg-open opens retrun error
- // but it tries to open it anyway using the console editor (nano, vim, other..)
- EnvironmentHelpers.ShellExec($"gedit {filePath} || xdg-open {filePath}", waitForExit: false);
- }
- else
- {
- if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
- {
- bool openWithNotepad = true; // If there is an exception with the registry read we use notepad.
-
- try
- {
- openWithNotepad = !EnvironmentHelpers.IsFileTypeAssociated("json");
- }
- catch (Exception ex)
- {
- Logger.LogError(ex);
- }
-
- if (openWithNotepad)
- {
- // Open file using Notepad.
- using Process process = Process.Start(new ProcessStartInfo
- {
- FileName = "notepad.exe",
- Arguments = filePath,
- CreateNoWindow = true,
- UseShellExecute = false
- });
- return; // Opened with notepad, return.
- }
- }
-
- // Open file wtih the default editor.
- using (Process process = Process.Start(new ProcessStartInfo
- {
- FileName = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? filePath : "open",
- Arguments = RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? $"-e {filePath}" : "",
- CreateNoWindow = true,
- UseShellExecute = RuntimeInformation.IsOSPlatform(OSPlatform.Windows)
- }))
- { }
- }
- }
- }
-
public static void OpenBrowser(string url)
{
if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))

Display a notification when file is not found