Code:
void LoadFile(string filePath)
{
using (TextReader tr = new StreamReader(filePath))
{
string contents = tr.ReadToEnd();
string[] lines = contents.Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
foreach (string line in lines)
{
string[] split = line.Split(new[] { '=' }, StringSplitOptions.RemoveEmptyEntries);
if (split.Length != 2)
continue;
Spells.Add(Convert.ToUInt32(split[0]), split[1]);
}
}
}
You could even do the above, using a text file or stream located in the application resources. (When you add a .txt file to the resources, accessing it from Properties.Resources.MyTextFile returns a string (the contents of the file))