How to read the local file in Xamarin Forms
Add text/HTML/JSON file in your Xamarin Form Project. Then change build action to Embedded Resource
Write the following code to access the file.
var assembly = typeof(AnyContentPageName).GetTypeInfo().Assembly; Stream stream = assembly.GetManifestResourceStream("TestFile.json"); string jsonContent = string.Empty; using (var reader = new System.IO.StreamReader(stream)) { jsonContent = reader.ReadToEnd();
}
No comments:
Post a Comment