I have saved some .json files in the shared library.
I have managed to read just fine in iOS by the code
string fileName = $\"Files/file_name.json\";
v
Add your "shared" file to your solution (in a folder within your PCL/NetStd/Shared project is fine, just set the build type to None
).
In your Android project, create a link to the file in the Assets
with a build type of AndroidAsset
.
BundleResource
.
Assets\her.png
her.png
Note: You can manually edit the .csproj
or perform a drop/drop from Finder/Explorer using the starting location of the file in your PCL/NetStd library but make you select create a link when you drop the file.
Now you can either use your own platform-dependent code via DI or use Xamarin.Essentials
to access these read-only app bundled files from your PCL/NetStd library.
using (var stream = await FileSystem.OpenAppPackageFileAsync("her.png"))
{
~~~
}