For anyone else who ends up in the same boat. This is the code I ended up using:
private char[][] maze = new char[20][];
// Stuff
private void InitialiseMaze()
{
for (int lp = 0; lp <= 19; lp++)
{
maze[lp] = new char[20];
}
}
// Stuff
private void LoadMaze()
{
// read in the text file and convert to a string.
string path = _mazePath + @ "\store\" + _currentLevel + ".map";
byte[] rawBytes = _storageDev.ReadFile(path);
char[] rawCharacters = System.Text.UTF8Encoding.UTF8.GetChars(rawBytes);
string tmpMap = new string(rawCharacters);
// Now split the text file into lines using the \r character from the text file
// note this will leave the \n character at the end of each line
string[] lines = tmpMap.Split('\r');
// Get the header, removing the \n
string header = lines[0].Trim('\n');
// check maze version and the dimensions of the maze
string[] bits = header.Split('|');
string ver = bits[0];
int width = int.Parse(bits[1]);
int height = int.Parse(bits[2]);
if (ver != "1.0")
{
throw new Exception("Maze version is incorrect");
}
for (int y = 1; y <= height; y++)
{
char[] row = lines[y].Trim('\n').ToCharArray();
for (int x = 0; x < width; x++)
{
maze[x][y-1] = row[x];
}
}
}