Hello,
You could refer to the following code and documentation to make your text file picker:
var customFileType = new FilePickerFileType(
new Dictionary<DevicePlatform, IEnumerable<string>>
{
{ DevicePlatform.iOS, new[] { "public.text" } }, // UTType values
{ DevicePlatform.Android, new[] { "text/plain" } }, // MIME type
{ DevicePlatform.WinUI, new[] { ".txt" } }, // file extension
{ DevicePlatform.macOS, new[] { "txt" } },
});
PickOptions options = new()
{
PickerTitle = "Please select a txt file",
FileTypes = customFileType,
};
var file = FilePicker.PickAsync(options);
For desktop platfroms, you could use file extension as your file picker types.
For Android, you need to use MIME type to set the file type, you could refer to this google source code to get more details about the file types corresponding to the MIME types: MimeUtils.java.
For iOS, you need to use UTI(Uniform Type Identifiers) to do it, please refer to this official comparison table: System-Declared Uniform Type Identifiers.
Best Regards,
Alec Liu.
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.