Fix Windows, Dispose processes
MODIFY
WalletWasabi/Helpers/IoHelpers.cs
WalletWasabi/Helpers/IoHelpers.cs
@@ -250,18 +250,26 @@ namespace System.IO
public static void OpenFolderInFileExplorer(string dirPath)
{
if (Directory.Exists(dirPath))
+ {
+ Process process = null;
+ try
{
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
- Process.Start(new ProcessStartInfo { FileName = "explorer.exe", Arguments = $"\"{dirPath}\"" });
+ process = Process.Start(new ProcessStartInfo { FileName = "explorer.exe", Arguments = $"\"{dirPath}\"" });
}
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
{
- Process.Start(new ProcessStartInfo { FileName = "xdg-open", Arguments = dirPath, CreateNoWindow = true });
+ process = Process.Start(new ProcessStartInfo { FileName = "xdg-open", Arguments = dirPath, CreateNoWindow = true });
}
else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
{
- Process.Start(new ProcessStartInfo { FileName = "open", Arguments = dirPath, CreateNoWindow = true });
+ process = Process.Start(new ProcessStartInfo { FileName = "open", Arguments = dirPath, CreateNoWindow = true });
+ }
+ }
+ finally
+ {
+ process?.Dispose();
}
}
}
@@ -269,10 +277,13 @@ namespace System.IO
public static void OpenFileInTextEditor(string filePath)
{
if (File.Exists(filePath))
+ {
+ Process process = null;
+ try
{
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
- Process.Start(new ProcessStartInfo { FileName = "notepad.exe", Arguments = $"\"{filePath}\"" });
+ process = Process.Start(new ProcessStartInfo { FileName = filePath, UseShellExecute = true });
}
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
{
@@ -282,7 +293,12 @@ namespace System.IO
}
else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
{
- Process.Start(new ProcessStartInfo { FileName = "open", Arguments = "-e " + filePath, CreateNoWindow = true });
+ process = Process.Start(new ProcessStartInfo { FileName = "open", Arguments = "-e " + filePath, CreateNoWindow = true });
+ }
+ }
+ finally
+ {
+ process?.Dispose();
}
}
}

Fix Windows, Dispose processes