If you try to read a file that is included in your project, it won't be in the IsolatedStorage
. You need to access it via Application.GetResourceStream
.
Here is a sample code to read a local text file:
private string ReadTextFile(string filePath)
{
var resourceStream = Application.GetResourceStream(new Uri(filePath, UriKind.Relative));
Stream myFileStream = resourceStream.Stream;
StreamReader myStreamReader = new StreamReader(myFileStream);
return myStreamReader.ReadToEnd();
}
Don't forget to set the Build action
to Content
on the properties of the file in Visual Studio.
ReadTextFile("data/stops.txt")