I created a small Windows Phone game with XNA, but I have some trouble with loading a text file from Content. I added the text file to my Content project and marked the Build Action to "Content". The static text file should be loaded when the game starts, but I always get an exception in this line of the method:
if (File.Exists(filename))
An exception of type 'System.MethodAccessException' occurred in mscorlib.ni.dll but was not handled in user code
If there is a handler for this exception, the program may be safely continued.
What is wrong? How can I load a text file from Content?
private const string filename = "Level1.txt";
public void LoadfromContent()
{
if (File.Exists(filename))
{
using (StreamReader reader = new StreamReader(File.OpenRead(filename)))
{
strs = reader.ReadLine().Split(';');
game1.HowManyEnemies = int.Parse(strs[1]);
}
}
}