Skip to content

Commit bdea1da

Browse files
tompnubMrJul
andauthored
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>
1 parent c9d6efb commit bdea1da

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

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

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,17 @@ private static bool Exec(string urlOrFile)
4949
}
5050
else if (OperatingSystemEx.IsWindows() || OperatingSystemEx.IsMacOS())
5151
{
52-
using var process = Process.Start(new ProcessStartInfo
52+
var info = new ProcessStartInfo
5353
{
5454
FileName = OperatingSystemEx.IsWindows() ? urlOrFile : "open",
55-
Arguments = OperatingSystemEx.IsMacOS() ? $"{urlOrFile}" : "",
5655
CreateNoWindow = true,
5756
UseShellExecute = OperatingSystemEx.IsWindows()
58-
});
57+
};
58+
// Using the argument list avoids having to escape spaces and other special
59+
// characters that are part of valid macos file and folder paths.
60+
if (OperatingSystemEx.IsMacOS())
61+
info.ArgumentList.Add(urlOrFile);
62+
using var process = Process.Start(info);
5963
return true;
6064
}
6165
else

0 commit comments

Comments
 (0)