好的,我仍在开发 Roller Dice 程序,我需要该程序在每次游戏重新开始时显示以前的高分。但是,当我输入代码时。它给了我留下的错误。名称“文件”不存在并且找不到名称空间名称 StreamReader?请帮忙
private void button2_Click(object sender, EventArgs e)
{
try
{
int scores;
int highscore = 0;
StreamReader inputFile;
inputFile = File.OpenText("HighScore.txt");
while (!inputFile.EndOfStream)
{
scores = int.Parse(inputFile.ReadLine());
highscore += scores;
}
inputFile.Close();
highscoreLabel.Text = highscore.ToString("c");
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}