Select and open a file

Hi all!
In an ios app, I need to read a text file (in my case a csv one), and I need the user can navigate in the icloud or phone folders. In other apps (for example I use a digital signature app) the user is able to navigate in the folder system and choose a document, to process it.
I really don’t know how approach this. I have activated filesharing and icloud in the capabilities but folderitem.showopenfiledialog is unavailable in ios apps. With specialfolder I can access to a specific file, but I can’t give to the user the choice.

Any suggestion?

Thanks a lot!

1 Like

I was looking for the same thing.

I ran into this topic on this forum: Store file to iCloud
It is not covering the selecting a file part. But it gives some insight to saving files to iCloud.

I hope there will be a SpecialFolder.iCloudFolder someday. Maybe there is even a feature request already. If not, somebody should definitely write a request.
Also, an OpenFileDialog might be useful for iOS apps, to access iCloud files and files stored on a connected USB drive.

Have a look at UIDocumentPickerViewController in iOSKit

Or “Document Picker iOS” example from MBS.

2 Likes

This is what I ended up using. Works like a charm!

I can connect with iCloud. But even with locally attached USB thumb-drives!

1 Like

I downloaded the code from your git-hub page. But noticed that the UIDocumentPickerView is not there.
Screenshot 2023-08-16 at 19.28.53

I also need to be able to select a folder. Or even better, a disk (SD card in an attached card reader)

In the MBS plugin I can set the UTI “public.folder” in the Types array. That seems to work.
I use the following code to get the folderitem I need:

Var folder As FolderItem = New FolderItem(URLs(0), FolderItem.PathModes.URL)

But when I inspect the folder, it doesn’t exist.

I want to be able to select a folder (or SD card) with a known sub-folder structure, and import certain files in multiple sub-folders

…when I run the app in a Simulator, the folder exists. But when I run it on the device, the app runs, but the folder I got via the URL doesn’t exist.
Does this have anything to do with some entitlements?

This did the trick to access the folder! :tada:

Var vNSURL As New NSURLMBS(url)
Var ok As Boolean
ok = vNSURL.startAccessingSecurityScopedResource