Xamarin file picker file types for IOS

Abinash Patra 46 Reputation points
2021-04-19T15:05:02.603+00:00

I have an xamarin app and I am using Essential File Picker for selecting files from library. I am trying to find a way to define doc and docx files for IOS which I am not getting it right. for Android I got it going. Below is the code I have used.

 private List<string> androidAcceptableList = new List<string> { "application/pdf", "image/*" }; //TODO:Read from configuration
            private List<string> iOsAcceptableList = new List<string> {  "application/pdf",
          "application/msword",
          "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
          "image/*"}; //TODO:Read from configuration

    var customFileTypes = new FilePickerFileType(new Dictionary<DevicePlatform, IEnumerable<string>> {
                    { DevicePlatform.iOS,iOsAcceptableList },
                    { DevicePlatform.Android, androidAcceptableList}
                });
var resp = FilePicker.PickAsync(new PickOptions { FileTypes = FileTypesList() });
Developer technologies .NET Xamarin
0 comments No comments
{count} votes

Accepted answer
  1. Anonymous
    2021-04-20T03:03:14.073+00:00

    Hello,​

    Welcome to our Microsoft Q&A platform!

    If you used FilePicker to open the file in iOS, actually it used UIDocumentPickerViewController to achieve it like following thread. Doc limitation is "com.microsoft.word.doc","org.openxmlformats.wordprocessingml.document"

    https://github.com/xamarin/Essentials/blob/main/Xamarin.Essentials/FilePicker/FilePicker.ios.cs

    But all documents should present in your iCloud, Files and in Google Drive will be shown if Google Drive is connected in user device. Do you put your doc file in the public files or iCloud.

    If still not work, you can try to create a dependenceService. Wirte native code like this thread:

    https://stackoverflow.com/questions/47865646/how-to-open-the-document-files-e-g-pdf-doc-docx-in-ios-mobile-when-a-button

    Best Regards,

    Leon Lu


    If the response is helpful, please click "Accept Answer" and upvote it.

    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.

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

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