-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Open
Description
Describe the bug
When trying to open a folder whose path contains a space using Launcher.LaunchFileAsync (or the LaunchDirectoryInfoAsync extension method) on macOS, the file path is interpreted as two separate files and an error written to the debug console, while the method returns true.
This is a similar issue to #17301 on Linux, as fixed in #17682
To Reproduce
- Create an empty C# .net8.0 Avalonia project using the Avalonia .NET MVVM App template, Avalonia 11.3.6.
- Add a button to MainWindow.axaml and the following code to its click event:
private void Button_OnClick(object? sender, RoutedEventArgs e)
{
Dispatcher.UIThread.InvokeAsync(async () =>
{
// replace <username> and <appfolder> with the relevant values, must be a valid folder path containing a space
Uri folderUri = new Uri("/Users/<username>/Library/Application Support/<appfolder>");
var storageResult = await StorageProvider.TryGetFolderFromPathAsync(folderUri);
// check that storageResult is a valid object whose properties represent the folder
bool result = await Launcher.LaunchFileAsync(storageResult);
// result == true
// Debug console:
// The files /Users/<username>/Library/Application and /Users/<username>/Documents/<pathtomysolution>/src/<avaloniaprojectfolder>/bin/Debug/net8.0/Support/<myapp-folder> do not exist.
});
}
- Set breakpoints, debug the project and press the button.
Expected behavior
The directory with a space in its path should open in Finder.
Avalonia version
11.3.6.
OS
macOS
Additional context
macOS version: Sequoia 15.6.1 (24G90)
My workaround is to run Launcher.LaunchUriAsync, which correctly opens the directory, although that has issues in Windows 10 and could lead to different results if the path is a file not a folder, etc.