Share via

pickup option xml

Dani_S 5,581 Reputation points
2024-08-13T14:22:39.09+00:00

Hi,

PickOptions options = new()

{

 PickerTitle = "Please select an external configuration",
``` FileTypes = FilePickerFileType.XML not exist why ?

 };
Developer technologies | .NET | .NET Multi-platform App UI
0 comments No comments

Answer accepted by question author

Wenyan Zhang (Shanghai Wicresoft Co,.Ltd.) 36,456 Reputation points Microsoft External Staff
2024-08-14T06:05:40.8266667+00:00

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.

Was this answer helpful?

1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.