A Microsoft open-source framework for building native device applications spanning mobile, tablet, and desktop.
Hello,
As described in the official doc - File picker - .NET MAUI | Microsoft Learn
Default file types are provided with FilePickerFileType.Images, FilePickerFileType.Png, and FilePickerFilerType.Videos. You can specify custom file types per platform, by creating an instance of the FilePickerFileType class
And you can refer to the following code:
async void DoPickCustomType()
{
var customFileType =
new FilePickerFileType(new Dictionary<DevicePlatform, IEnumerable<string>>
{
{ DevicePlatform.iOS, new[] { "public.xml" } },
{ DevicePlatform.Android, new[] { "application/xml" } },//xml type
{ DevicePlatform.WinUI, new[] { ".xml" } }
});
var options = new PickOptions
{
PickerTitle = "Please select a xml file",
FileTypes = customFileType,
};
var result = await FilePicker.Default.PickAsync(options);
...
}
Best Regards,
Wenyan Zhang
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.