'How can one get actual file path from filepicker
Solution 1:[1]
It is a file path of the app. If you have the Android Studio, you can see the folder in the simulator just like the following picture.
In addition, you can get the folder path with the following code:
string path = this.ExternalCacheDir.Path;
You can check the official document about the file path: https://developer.android.com/training/data-storage/app-specific#external-cache-create
Update?
I had test the FilePicker.PickAsync
method, the Result.FullPath
of it will always be a string like this: /storage/emulated/0/Android/data/{your app package name}/cache/2203693cc04e0be7f4f024d5f9499e13/3034fef08ac24d6c960492dc2b6c090c/
+ filename
of the file you picked.
But the file you picked is in the folder of the Android Share Folder such as Alarm ,/Android/media, Download and so on. So the File.Delete()
just delete the copy of the file you picked. But the file is still here.
In addition, you need to grant the app Management Of All Files permission or read and write external storage permission before you delete the file in the share folder. You can search how to do it and read the official document:https://developer.android.google.cn/training/data-storage/shared/media.
Finally, I don't known whether there is a api or package for xamarin.forms which can pick a file in the share folder and return the correct path of it or not. You may need to use the dependency service on the android project.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 |