How to add custom file extension in Xamarin.Essentials file picker in all 3 platforms

Sk 61 Reputation points
2024-03-21T10:31:05.3466667+00:00

I want to add custom file extension i.e. ".s37" in file picker filtering options. In UWP with the below code it is working fine but In android and ios not working

private async Task SelectFileClicked(object UTType)
        {
            var customFileType =
                new FilePickerFileType(new Dictionary<DevicePlatform, IEnumerable<string>>
                {
                { DevicePlatform.iOS, new[] {"s37" } },
                { DevicePlatform.Android, new[] { "s37" }},
                { DevicePlatform.UWP, new[] { "s37" } },
                });
            var file = await FilePicker.PickAsync(new PickOptions
            {
                FileTypes = customFileType,
                PickerTitle = "Pick an PDF"
            });
            if (file != null)
            {
                LblSelectedFileVisible = true;
                LblSelectedFileName = file.FileName;
              
            }
        }
Xamarin
Xamarin
A Microsoft open-source app platform for building Android and iOS apps with .NET and C#.
5,294 questions
{count} votes