简体   繁体   English

如何允许应用程序用户选择可以保存应用程序文档的文件夹位置

[英]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.

相关问题 如何允许用户选择文件夹? - How to allow user to select a folder? 如何使用C#访问iOS App的Documents文件夹 - How can I access Documents folder of iOS App with C# 允许用户在 C# WinForms 应用程序中选择文件/文件夹 - Allow user to choose file/folder in C# WinForms app 如何获取用户文档目录的位置? - How can I get the location of a user's Documents directory? 如何在用户的 AppData 文件夹中的 app 文件夹中创建一个文件夹,例如 C:\\User\\AppData? - How can I create a folder in the app folder in the user's AppData folder e.g. C:\User\AppData? 应用程序如何分辨用户在“数据库文件夹”对话框中选择的文件夹? - How can the app tell which folder the user selected in the Database Folder dialog? 如何在C#控制台应用程序的行首处允许用户输入? - How can I allow user input from the beginning of the line in C# console app? 如果用户缺乏写入权限,如何允许用户修改存储在 app.config 中的连接字符串? - How can I allow the user to modify connection strings stored in app.config if they lack write permissions? 如果X分钟内未保存文本并且用户想要关闭该应用程序,该如何发送消息框? - How can I send a message box if text hasn't been saved within X mins and the user wants to close the app? 开发过程C#桌面应用程序中Data文件夹的正确位置在哪里 - where is the correct location for Data folder in developing process C# deskTop app
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM