我目前正在开展一个涉及大量学生的学校项目,我必须按字母顺序插入一个新学生并进行一些其他计算。我很难得到它,所以它只添加了一次新学生。我有一个 if 语句,但它似乎无法正常工作。
`//this adds the new student
StreamWriter changeFile = new StreamWriter("Students.txt", true);
string newStudent = "(LIST (LIST 'Malachi 'Constant 'A ) '8128675309 'iwishihadjessesgirl@mail.usi.edu 4.0 )";
// this is where I am getting stumped
if (File.Exists(newStudent))
{
changeFile.Close();
}
else
{
changeFile.WriteLine(newStudent);
changeFile.Close();
}`
每当我像这样运行代码时,它只会在我每次调试程序时添加新学生。我怎样才能让它只加他一次?