0

I'm writing an application using Avaloniaui. I'm pretty sure the question is for .NET in general, though. I want the user to be able to specify an app that will be used to open certain file types. In Windows I can just browse to the executable and voilà. In MacOS I can browse to a file and select it, like I would expect. But when I use the filebrowser or drag and drop with an application 'Applications' folder, the result is an empty list (IEnumerable).

public async void OpenFileBrowser(object source, RoutedEventArgs args)
{
    var files = await FileBrowserResult("Open Executable", "Executables", "*"); 
    if (files.Count > 0)
    {
        IStorageFile file = files[0];
        Debug.WriteLine("Selected: " + files[0].Path.LocalPath);
    }
    else
    {
        Debug.WriteLine("No file selected");
    }
}

The same happens for Drag and Drop result. f.y.I, I have not changed any sandbox settings and am developping in VS Code, .NET 8.

1 Answer 1

0

The reason was my lack of knowledge how Apple handles installed apps.
They are actually folders, where the executable is somewhere within. Treating the dropped app as a folder solved the problem.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.