最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Use Drag and Drop or a filebrowser on macos .NETC# - Stack Overflow

programmeradmin2浏览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.

发布评论

评论列表(0)

  1. 暂无评论