I use a button to find a file in the phone:
private void button_save_Click(object sender, System.EventArgs e)
{
Intent chooseFile = new Intent(Intent.ActionGetContent);
chooseFile.SetType("*/*");
chooseFile = Intent.CreateChooser(chooseFile, "Choose a file");
StartActivityForResult(chooseFile, 1000);
}
And then I try to use the given path to open the selected file:
protected override void OnActivityResult(int requestCode, [GeneratedEnum] Result resultCode, Intent data)
{
base.OnActivityResult(requestCode, resultCode, data);
if (requestCode is 1000 && resultCode is Result.Ok)
{
var uri = data.Data;
string path = uri.Path;
Java.IO.File file = new Java.IO.File(path);
}
}
but the format of uri.Path
is incompatible with Java.IO.File
and the file is not opened. How can I get a compatible full path to a file?