question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Maui FilePicker results in This platform does not support this file type.

See original GitHub issue

Description

I am building a desktop app in .NET Maui which targets Windows and MacOS. When using the built-in FilePicker on Mac (Catalyst) I get the following error:

{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…}

I have tried multiple file types, including csv, jpg, text/csv but nothing works.

`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)
    {

    }
}`

Steps to Reproduce

  1. Create a new Maui app.
  2. Remove iOS and Android targets from project file.
  3. Execute the shared code

Version with bug

6.0.400

Last version that worked well

Unknown/Other

Affected platforms

macOS

Affected platform versions

MacCatalyst 14.0

Did you find any workaround?

The documentation does say that I should “Enable iCloud capabilities” but does not provide any links or other information regarding this. I did some digging, and found some documentation that says that it necessary to do this via the Entitlements.plist file which I did but it seems to only be relevant when publishing your app to the App store which I am not during development. I don’t even care about iCloud right now. I just want to select a CSV file from my own desktop.

Relevant log output

{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…}

Issue Analytics

  • State:open
  • Created a year ago
  • Reactions:1
  • Comments:10 (3 by maintainers)

github_iconTop GitHub Comments

4reactions
cdavidyoungcommented, Oct 20, 2022

I found that if I use MacCatalyst instead of MacOS it works fine:

         var zipFileType = new FilePickerFileType(new Dictionary<DevicePlatform, IEnumerable<string>>
                                                  {
                                                     { DevicePlatform.iOS, new[] { "public.archive" } },
                                                     { DevicePlatform.Android, new[] { "application/zip" } },
                                                     { DevicePlatform.WinUI, new[] { "zip" } },
                                                     { DevicePlatform.MacCatalyst, new[] { "zip" } },
                                                        });
         var optionsZip = new PickOptions
            {
               PickerTitle = "Please select a previously backed up zip file",
               FileTypes = zipFileType
            };
2reactions
MGohilcommented, Dec 26, 2022

Providing supported file type options disables all those files in File Browser in Android. So, I am unable to pick those files. If I do not mention any file types (filePicker.PickAsync(null)) , it woks good, but shows all files.

I want to restrict to show only supported files to pick Ex. png, jpg, pdf.

image

Read more comments on GitHub >

github_iconTop Results From Across the Web

.NET Maui FilePicker results in This platform does not ...
I don't think it has something to do with ICloud. It is just the wrong file type. File types are different on MacOS.They...
Read more >
File picker - .NET MAUI
Learn how to use the .NET MAUI IFilePicker interface in the Microsoft.Maui.Storage namespace, which lets a user choose one or more files ......
Read more >
Use .NET MAUI FilePicker to Pick PDFs, Images ... - YouTube
NET MAUI 0:12 What is File Picking? 1:18 Implement Single File Picker 8:34 Multiple Files Picker 11:32 Pick Custom File Types 14:14 Want...
Read more >
Pick Images, Videos, PDFs, and More in .NET MAUI using ...
In this article, you'll learn how to implement FilePicker in your .NET MAUI application. The FilePicker class lets a user pick a single...
Read more >
2022 - Dave's Tech Blog
NET MAUI on Android, iOS, Mac Catalyst, and Windows. The main problem with my implementation was that the FilePicker for picking local audio...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found