question

AbinashPatra-9229 avatar image
0 Votes"
AbinashPatra-9229 asked LeonLu-MSFT edited

Xamarin file picker file types for IOS

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() });
dotnet-xamarin
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

LeonLu-MSFT avatar image
1 Vote"
LeonLu-MSFT answered LeonLu-MSFT edited

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.


· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Thanks, this is what I wanted "com.microsoft.word.doc","org.openxmlformats.wordprocessingml.document"

0 Votes 0 ·

Great, I move comment to answer.

1 Vote 1 ·