You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

.NET Maui macOS平台FilePicker报文件类型不支持错误求助

.NET Maui macOS(Catalyst)平台FilePicker报错:不支持该文件类型

问题现象

  • 开发支持Windows和macOS的.NET Maui桌面应用时,macOS(Catalyst)平台使用内置FilePicker抛出以下错误:

System.PlatformNotSupportedException: This platform does not support this file type.
at Microsoft.Maui.Storage.FilePickerFileType.GetPlatformFileType(DevicePlatform platform)
at Microsoft.Maui.Storage.FilePickerFileType.get_Value()
at Microsoft.Maui.S…

  • 尝试过csv、jpg、text/csv等多种文件类型定义,均无法解决问题

相关代码

public async Task ImportCSV()
{
    try
    {
        var customFileType = new FilePickerFileType(
                new Dictionary<DevicePlatform, IEnumerable<string>>
                {
                    { DevicePlatform.WinUI, new[] { ".csv" } },
                    { DevicePlatform.macOS, new[] {"csv"} }
                });

        PickOptions options = new()
        {
            PickerTitle = "Please select a csv file",
            FileTypes = customFileType
        };

        var file = await FilePicker.Default.PickAsync(options);

        if (file != null)
        {
            string filePath = AppStateService.fixMacFilePath(file.FullPath);

            AppStateService.AppState.csvFilePath = filePath;

            await InitiateCsvMapping();
        }
    }
    catch (Exception ex)
    {

    }
}

环境与疑问

  • 使用环境:Visual Studio Community 2022 for Mac Preview版本17.4 Preview(17.4 build 715)
  • 文档提到需要“启用iCloud功能”但无详细说明;查阅资料得知需通过Entitlements.plist文件配置,但Maui项目中无此文件,且该配置似乎仅适用于App Store发布
  • 当前处于开发阶段,仅需从本地桌面选择CSV文件,请问:未配置iCloud是否是导致该问题的原因?

内容的提问来源于stack exchange,提问作者Julian Dormon

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.22 09:09:18