我有一个带有文本文件的游戏程序,它以高分预加载到程序中。我需要程序仅在达到高分时更新程序中的文本框。
目前,高分文本框的返回值是每个条目或游戏会话(掷骰子)。
private void button4_Click(object sender, EventArgs e)
{
    try
    {
        string highScore;
        StreamReader inputFile;
        inputFile = File.OpenText("Highscore.txt");
        HighscoreBox.Items.Clear();
        while (!inputFile.EndOfStream)
        {
            highScore = inputFile.ReadLine();
            HighscoreBox.Items.Add(highScore);
        }
        inputFile.Close();
    }
    catch (Exception ex)
    {
        MessageBox.Show(ex.Message);
    }