Skip to main content
AI Assist is now on Stack Overflow. Start a chat to get instant answers from across the network. Sign up to save and share your chats.

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

6
  • On Android, I keep getting exceptions that the file is not found, when checking if it exists or trying to copy. Currently, the filepath i'm passing is something like "file:///android_asset/name.pdf". Commented Oct 16, 2018 at 11:10
  • That won't work, since your file isn't lying on a proper file path but is being compiled into your application's assets. Even worse, another app won't be able to access it, since other apps are not allowed to access your app's (internal) assets. So basically you need to get the file content by using Assets.Open("name.pdf"); and write that to a public file location so that the file can be accessed by other apps. Commented Oct 16, 2018 at 11:53
  • Ah, ok. Isn't that the reason we are copying the file in the first place? So if the file is in my assets, i would have to use Assets.Open("name.pdf"), write it that to a public file location and i wouldn't need to copy it? What's a public location that all android phones have? Commented Oct 16, 2018 at 13:29
  • Android.OS.Environment.GetExternalStoragePublicDirectory(Android.OS.Environment.DirectoryDocuments) should return a public directory to use. By default your app, it's assets and even all files it downloads or generates by itself are put inside their own sandbox, which is closed to the outside world (meaning other apps on the same device). The android solution basically asks the other apps, if they can handle the file and then shows the user which apps can use that file. So the file has to made accessible to them by either copying or writing them to a place they are "allowed" to access. Commented Oct 16, 2018 at 13:35
  • I just saw that my answer was lacking setting up the fileprovider information in the manifest. I updated that in my answer in the android section. Commented Oct 16, 2018 at 13:44