How to open the root folder with UIDocumentPickerViewController

176 views Asked by At

I want to show most root folder with UIDocumentPickerViewController on presentation.

UIDocumentPickerViewController has directoryURL feature. But I can't access the URL i want to access. Example usage documentPickerController.directoryURL = url

This is where I want it to start from

1

1- Tried documentPickerController.directoryURL = url but couldn't find the url i want to access.

2- Also this one didn't work for me.

func getDocumentsDirectory() -> URL { // returns your application folder
    let paths = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)
    let documentsDirectory = paths[0]
    return documentsDirectory
}

let path = getDocumentsDirectory().absoluteString.replacingOccurrences(of: "file://", with: "shareddocuments://")
let url = URL(string: path)!

UIApplication.shared.open(url)

0

There are 0 answers