Browse Source

Update BclLauncher.cs to use ArgumentList property (#19713)

Using the ArgumentList property avoids having to escape spaces and special characters, which would otherwise cause the open command to fail and either split the argument string or not find the required files and folders with special characters.

Co-authored-by: Julien Lebosquain <julien@lebosquain.net>
pull/20730/head
tompnub 1 month ago
committed by GitHub
parent
commit
bdea1dad0a
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 10
      src/Avalonia.Base/Platform/Storage/FileIO/BclLauncher.cs

10
src/Avalonia.Base/Platform/Storage/FileIO/BclLauncher.cs

@ -49,13 +49,17 @@ internal class BclLauncher : ILauncher
}
else if (OperatingSystemEx.IsWindows() || OperatingSystemEx.IsMacOS())
{
using var process = Process.Start(new ProcessStartInfo
var info = new ProcessStartInfo
{
FileName = OperatingSystemEx.IsWindows() ? urlOrFile : "open",
Arguments = OperatingSystemEx.IsMacOS() ? $"{urlOrFile}" : "",
CreateNoWindow = true,
UseShellExecute = OperatingSystemEx.IsWindows()
});
};
// Using the argument list avoids having to escape spaces and other special
// characters that are part of valid macos file and folder paths.
if (OperatingSystemEx.IsMacOS())
info.ArgumentList.Add(urlOrFile);
using var process = Process.Start(info);
return true;
}
else

Loading…
Cancel
Save