Hi;
I have developed a MCQ based learning game. A user has to play the game repeatedly to improve his learning. For each session of game, player gets score. I want to write the score in a single file for every session. e.g. I want to print user name and his score for first game in first line of file and for 2nd game in second line and so on.
At the moment, every time a new session is played it overrides the earlier line. I need some help with the below code.
Re: Problem in writing to a file using StreamWriter
Take a look at "FileMode" in the help index. Your use of FileMode.Create will always create a new file including overwriting the file if it already exists. Instead you want to create a file if it doesnt exist but append to a file if it does exist.
Yeah, the second one overwrites the first.
What I want is if first game score was
Player1 90
Then second game score should not overwrite it rather appear alongwith it in file when I check file after playing game 2 e.g.
Player1 90
Player1 95
Player1 96
and so on...
Overload resolution failed because no accessible 'New' can be called with these arguments:
'Public Sub New(path As String, append As Boolean)': Value of type 'System.IO.FileStream' cannot be converted to 'String'.
'Public Sub New(stream As System.IO.Stream, encoding As System.Text.Encoding)': Value of type 'Boolean' cannot be converted to 'System.Text.Encoding'.
Seems to be variable type mismatch (Bolean and string).
No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.