Folder picker in Xamarin Forms

Pelin Konaray 291 Reputation points
2022-02-01T08:36:16.757+00:00

I have an app that is file management app like drive. I want to add sync mechanism with Xamarin Forms app.

So the sync mechanism I want is this: User will choose a folder from my app, and will choose a folder from their phone. App will sync both of them, when added a file or folder to this folders.
For example:
When a file is added to the selected folder (on the phone) from the app, this file will be uploaded to the remote server with the help of my app. Or
When a file is added to the folder (in the app) selected from the app, this file will be downloaded from the remote server to the selected folder on the phone with the help of my app.

My app will work in the background or sync will be triggered with button in my app. (Because I know ios background restricts operations. But it will be another research subject for me.)

For this reason I am looking up a folder picker. But I didn't find any plugin. When I searched, I saw that it was said that it can be done with dependency services.

So I want to get all file system structure of phone and show it with a listview for select a sync directory. I follow this documentation for get all file system structure of phone:
for ios: https://learn.microsoft.com/en-US/xamarin/ios/app-fundamentals/file-system
for android: https://learn.microsoft.com/en-US/xamarin/android/platform/files/

But I stuck in ios. Because I couldn't get all directories with this commands. For example I want to select a gallery album for sync. But I couldn't access gallery album path. I am accessing with image pickers but I don't want select a file, I want to select gallery album.

I reviewed Xamarin.Essentials Media Picker and File Picker source code in github. I also reviewed Plugin.FilePicker source code in github. All of them use UIDocumentPickerViewController or UIImagePickerController. But these for selecting file. These not selecting folder.

What can I do?
Thanks in advance.

Xamarin
Xamarin
A Microsoft open-source app platform for building Android and iOS apps with .NET and C#.
5,287 questions
{count} votes