Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 89864

While opening pdf "this file could not be accessed". c#

$
0
0

I have an app that builds a listView of all the pdfs in a specified folder already located on the android machine. The file path and name are stored in an array called files[] and I can grab a full path with files[e.Position]. Here is my c# code

public void documentListView_ItemClick(object sender, AdapterView.ItemClickEventArgs e)
        {       
        var bytes = File.ReadAllBytes(files[e.Position]);


                Android.Net.Uri pdfPath = Android.Net.Uri.Parse(files[e.Position]);

                Intent intent = new Intent(Intent.ActionView);
                intent.SetDataAndType(pdfPath, "application/pdf");
                intent.SetFlags(ActivityFlags.NewTask);

               StartActivity(intent);
}

I have also added this to my manifest

<uses-persmission android:name="android.permissions.READ_EXTERNAL_STORAGE" />
<uses-persmission android:name="android.permissions.WRITE_EXTERNAL_STORAGE" />

Every time i click the button it starts to open adobe(which is great) and then it says "this file could not be accessed".
However, I can open the file directly by going to the folder. Any Ideas?


Viewing all articles
Browse latest Browse all 89864

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>