Maui FilePicker results in This platform does not support this file type.
See original GitHub issueDescription
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
- Create a new Maui app.
- Remove iOS and Android targets from project file.
- 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:
- Created a year ago
- Reactions:1
- Comments:10 (3 by maintainers)
I found that if I use MacCatalyst instead of MacOS it works fine:
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.