Search code examples
xamarin.iosxamarin.formsicloud-driveicloud-documents

Xamarin IOS file picker : unable to get selected file from icloud drive


I've installed filepicker control from Nuget and added tried adding reference from MonoTouch10 folder and later from github to my xamarin.ios project.

FileData file = await CrossFilePicker.Current.PickFile();

if (file != null) { }

this is the code i added to my browse button, after selecting a file from iCloud drive, control never comes to "if condition".

and again when i click on browse button for second time, app crashes saying "only one operation can be active at a time".


Solution

  • To answer my own question, i customized in plugin, like

    1. Used DocumentPicker_DidPickDocumentAtUrls event instead of DocumentPicker_DidPickDocument.

    2. while returning selected file used

       new FileData(e.FilePath, e.FileName, () =>
              {
                  var url = new Foundation.NSUrl(e.FilePath);
                  return new FileStream(url.Path, FileMode.Open, FileAccess.Read);
              })
      

    This solved my issue. Thanks.