Reputation: 1202
I have data.xlsx
file in Assets
folder and need to get its path to apply some library.
Found several solutions here but neither works for me. For example - File Not Found Exception In Xamarin program
I tried to use file:///android_asset/data.xlsx
but here is no file too.
I checked the path with: System.IO.File.Exists(filePath);
So how to get path to this file? Maybe I have to place it in different folder?
Update: possibly I can solve it this way: java.io.FileNotFoundException: This file can not be opened as a file descriptor; it is probably compressed
But I can't find where to place it.
Update: this question is about Java and this is unclear how to use this solution in Xamarin.Android: How to get the android Path string to a file on Assets folder?
Upvotes: 1
Views: 11984
Reputation: 1202
Looks like it's impossible.
Closest solution is to write file to Cache.
Upvotes: 0
Reputation: 104
in general using Xamarin.android , you can use this code :
private string _fileName {get;set;}
public string FileFullPath
{
get
{
return Path.Combine(Android.OS.Environment.GetExternalStoragePublicDirectory(Android.OS.Environment.DirectoryPictures),_fileName);
}
}
Hope it helps.. :)
Upvotes: 1
Reputation: 2124
Looks like the file isn't included in the APK. Ensure that the Build Action of the file in the Asset-folder is set to AndroidAsset.
Upvotes: 3