I'm new on this website!
I'm experiencing some problem in Xamarin Android opening a file. I have to open a file which contains a list of foods and relative calories, split by some delimiter chars.
When I wrote this code for Xamarin iOS I didn't have any problem with the following code:
outputText.Text = "The selectable foods are:\n\n"; foreach (string line in File.ReadLines("Cibi.txt")) { string[] cibsel = line.Split(delimiterChars); outputText.Text += cibsel[0] + "\n"; } Of course in iOS the file was stored inside Resources folder.
But when I started to write the same code in Xamarin Android I'm starting to experiencing some errors.
First the program rusn into an exception because Visaul Studio can't find the path of the file (stored inside Assets folder). Then I found on Xamarin tutorial that suggested to use Streamreader.ReadLine() instead File.Readlines(), but I obtain the following error:
Can not convert type 'char' to 'string'.
The program must only read a food and calories from a file and return, as output, only the name. How I can do this without experiencing that kind of error?
Thanks in advance!
Enrico