[英]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. 我有一个xamarin.forms应用程序,我想允许应用程序(android / iOS / windows)的用户能够在应用程序的开头选择一个文件夹位置,所有与应用程序相关的文档应保存在该特定文件夹中。
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. 现在,当我尝试构建一个简单的应用程序,它从我创建的文件夹中读取xml文件并在列表视图上显示数据。 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.
我浏览了android中的文件管理器,看看文件在Android设备上的物理位置,但找不到任何带有应用程序名称的文件夹。
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. 这个要求背后的原因是,应用程序将记录一个mp3文件并将录音保存到选定的文件夹。 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. 为了能够使用下面的任何可能性,您必须在
Xamarin.Forms
编写特定于平台的代码,然后公开一些可以在PCL
项目中使用的接口。
Android:- 安卓: -
There is a post Choose File Dialog on how to create a file dialog selector (with directory changer), although not in Xamarin
. 有一个后选择文件对话框如何创建一个文件对话框,选择(与目录换),虽然不是在
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. 有一个
Xamarin
教程这里可以引导您了解如何创建一个简单的文件浏览器。
iOS :- iOS : -
For iOS you may be interested in the iOS
Document Picker View Controller
, here . 对于iOS,你可能有兴趣在
iOS
Document Picker View Controller
, 在这里 。
There is an extensive tutorial of how to complete this using Xamarin
here . 还有就是如何完成这种使用广泛的教程
Xamarin
这里 。
(pictures are from Xamarin
website) (图片来自
Xamarin
网站)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.