Read file in Shared Library Xamarin c#

前端 未结 2 1803
花落未央
花落未央 2021-01-24 08:21

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         


        
2条回答
  •  遇见更好的自我
    2021-01-24 08:36

    Are these files static (as in, they are part of the installation package), or are they saved by the application at runtime?

    If they are static, you need to put them in different places depending on the platform.

    For iOS you put the files in Resources, with a build type of BundleResource and access them with NSBundle.MainBundle.PathForResource.

    For Android, the files go in Assets, with a build type of AndroidAsset, and access them with Assets.Open.

    This page gives you more details.

提交回复
热议问题