我想选择用于在android表单中保存图像的文件夹,请有人帮我实现这一目标。
我已经通过以下方法做到了
public string OpenFolder()
{
activity = Xamarin.Forms.Forms.Context as MainActivity;
activity.Intent = new Intent();
activity.Intent.SetAction(Intent.ActionOpenDocumentTree);
activity.StartActivityForResult(activity.Intent, REQUEST_CODE_OPEN_DIRECTORY);
return RealPath;
}
选择文件夹后,我们可以轻松获取路径。
activity.ActivityResult += (object sender, ActivityResultEventArgs e) =>
{
FolderPath = e.Intent.Data;
string DummyPath=FolderPath.Path;
OriginalPath = DummyPath.Split(':')[1];
RealPath = "/storage/emulated/0/" + OriginalPath;
};
答案 0 :(得分:0)
对,我想您问如何选择文件夹?
这应该为您指明正确的方向
https://github.com/xamarin/monodroid-samples/tree/master/android5.0/DirectorySelection