简体   繁体   中英

How to allow app user to select a folder location where in app documents can be saved

I have a xamarin.forms app, I would like to allow users of app (android/ iOS/ windows) to be able to select a folder location at the start of the app and all the app related documents should be saved in that particular folder.

For now when I try to build a simple app which reads a xml file from the folder I create and display data on a list-view. I browsed through the file manager in android to see where the file is located physically on android device, but could not find any folder with app name.

In simple words I want a folder on the device to be created, which will be selected by the user. And accessible from file manager.

The reason behind this requirement is, the app is going to record a mp3 file and save a recording to a selected folder. So whenever the user wants to change his mobile he can always copy the recording to the new mobile and not loose any of the recordings.

To be able to use any of the possibilities below you will have to write platform-specific code in Xamarin.Forms and then expose some interface that you can use back in your PCL project.

Android:-

There is a post Choose File Dialog on how to create a file dialog selector (with directory changer), although not in Xamarin .

You will want to point the starting location to a shared folder of some kind.

There is a Xamarin tutorial here that walks you through how to create a simple file browser.

iOS :-

For iOS you may be interested in the iOS Document Picker View Controller , here .

There is an extensive tutorial of how to complete this using Xamarin here .

在此输入图像描述

(pictures are from Xamarin website)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM