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

sandeepamssandeepams USMember ✭✭

Hi all,

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".

I used this plugin : Xam.Plugin.FilePicker

Best Answer

  • sandeepamssandeepams US ✭✭
    Accepted Answer

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

    Used "DocumentPicker_DidPickDocumentAtUrls" event instead of "DocumentPicker_DidPickDocument".
    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.

Answers

  • sandeepamssandeepams USMember ✭✭
    Accepted Answer

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

    Used "DocumentPicker_DidPickDocumentAtUrls" event instead of "DocumentPicker_DidPickDocument".
    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.

  • Hi Sandeepams

    can you please provide the full demo for this File picker in IOS

    thanks
    Prashanth

  • sandeepamssandeepams USMember ✭✭

    Hi Prashath, check the attachment below, this is the customized version of existing plugin code, please not the changes are mentioned in my above post.. Just open the solution, rebuild the IOS project and copy the dlls(Plugin.FilePicker.Abstractions && Plugin.FilePicker) to your project.

    if this is not clear, please let me know, i'm happy in helping you.

  • MProtocolMProtocol Member ✭✭
    edited January 2018

    Hi, I have the same problem, but the above solution is still not working,

    When iCloud is openend it is not possible to select a file from the iCloud service all the files are disabled,
    and when I select a file nothings happens, the iCloud view keeps showing and does nothing.

    Any ideas?

  • RPrashanthRPrashanth Member

    Hi Sandeepams
    please go through the png file , i'm facing errors in code from the attached demo

    thanks
    Prashanth

  • santosh_g31santosh_g31 Member ✭✭

    Hi Sandeep,

    I have got your solution working on iphone and iphone simulator but nothing happens on ipad .....the browse menu doesn't show up at all for the PickFile call.
    Any ideas please ?

    Thanks,
    Santosh

  • JurgenJurgen Member ✭✭

    Also having issues with iPad. Any help would be appreciated !

Sign In or Register to comment.