How to open Files app (iOS 11) programmatically?

I have a file in my Documents folder, I need to open the file from Icloud.

I've been set UIFileSharingEnabled and LSSupportsOpeningDocumentsInPlace as described in for providing access to documents stored locally.

Now I want to provide for users ability to open "Files" app from my app. I want to open "Files" on my app folder programmatically. After that user there whey should share or move files to another app folders.

Best Answer


  • PremNath_RajaSekaranPremNath_RajaSekaran INMember ✭✭
    edited October 2017

    Thanks, @TedRogers I will implement and let you know. If I faced any issue I will post a reply

  • ShrutiBharadwajShrutiBharadwaj USMember

    @PremNath_RajaSekaran were you able to achieve that? Please share the code as I am unable to find PresentViewController in this

  • Here is a refactor of what @TedRogers posted. It worked for me.

    I made a class variable:
    UIDocumentPickerViewController FilePicker;

    in ViewDidLoad, I put this:

        FilePicker = new UIDocumentPickerViewController(new string[] { UTType.Data, UTType.Content }, UIDocumentPickerMode.Import);
        FilePicker.WasCancelled += FilePicker_WasCancelled;
        FilePicker.DidPickDocumentAtUrls += FilePicker_DidPickDocumentAtUrls;     

    in the body of the class I put these methods:

    partial void OpenFileDialogButton_TouchUpInside(UIButton sender)
        // FilePicker is a UIDocumentPickerViewController
        PresentViewController(FilePicker, true, null);
    private void FilePicker_DidPickDocumentAtUrls(object sender, UIDocumentPickedAtUrlsEventArgs e)
        // throw new NotImplementedException();
        Console.WriteLine("url = {0}", e.Urls[0].AbsoluteString);
        //bool success = await MoveFileToApp(didPickDocArgs.Url);
        var success = true;
        string filename = e.Urls[0].LastPathComponent;
        string msg = success ? string.Format("Successfully imported file '{0}'", filename) : string.Format("Failed to import file '{0}'", filename);
        var alertController = UIAlertController.Create("import", msg, UIAlertControllerStyle.Alert);
        var okButton = UIAlertAction.Create("OK", UIAlertActionStyle.Default, (obj) =>
            alertController.DismissViewController(true, null);
        PresentViewController(alertController, true, null);
    private void FilePicker_WasCancelled(object sender, EventArgs e)
        return; // throw new NotImplementedException();
Sign In or Register to comment.