I am developing an app which enables the user to select a file and do processing on it after getting the path of it, I have written a code which gets me the path like this
private void OpenFile()
{
Intent i = new Intent(Intent.ActionGetContent);
i.SetType("application/zip");
StartActivityForResult(i,0);
}
In activity for result I am extracting the path as follows:
protected override void OnActivityResult(int requestCode, Result resultCode, Intent data)
{
base.OnActivityResult(requestCode, resultCode, data);
if (requestCode == 0)
{
if (resultCode == Result.Ok)
{
string uri = data.DataString;
System.Uri myUri = new System.Uri(uri, System.UriKind.Absolute);
Android.Net.Uri uris = Android.Net.Uri.FromParts(data.Scheme, myUri.LocalPath, myUri.Fragment);
// string a= myUri.LocalPath;
System.IO.Stream input= ContentResolver.OpenInputStream(uris);
string uri = data.DataString;
ZipLogic.Unzip(uri);
}
}
}
And the results are in such pattern:
content://com.android.externalstorage.documents/document/xxxx-83BB%3xxx%2Fxxx.zip
But this path when I try to access from returns DirectoryNotFound Exception I am unable to resolve how to open this path as a Stream.