This is probably something mind-numbingly obvious, but I'm new to c# so be gentle...
I have an application which (in theory) parses a text file into an array. Despite the text file being a peer of the aspx file I can't get the relative path right. Don't know if it makes any difference (I'd assume not) but I'm using code-behind.
My folder structure looks like this:
- default.aspx
- default.aspx.cs
- default.aspx.designer.cs
- album.cs
- albums.txt
- web.config
And this is the code I'm using:
protected void Page_Load(object sender, EventArgs e)
{
string[] allLines = File.ReadAllLines(@"Albums.txt");
Album[] Albums = new Album[allLines.Length];
for (int i = 0; i < allLines.Length; i++)
{
string[] lineSplit = allLines[i].Split(',');
Albums[i] = new Album();
Albums[i].ID = Convert.ToInt32(lineSplit[0]);
Albums[i].title = lineSplit[1];
Albums[i].keyName = lineSplit[2];
}
}
However, when I build it I get an error saying albums.txt can not be found, and it fails.
Any pointers would be greatly appreciated.
Ben