:laugh:
That's a harder question to answer than you think... :D
The reason it's hard to answer is that save games (or any file data for that matter) are not all the same. Some are straight text, others are XML, some are binary, others are databases, yet others are completely proprietary formats that use bits of each of these! So it's hard to say "Here is the code, it saves your game" because it really depends on what you feel is important in a save game file: do you want it readable by anyone who cares to open it in Notepad? Or do you want it encrypted so that it is hard for hackers to play with your game? Both types (and everything inbetween) have been used for save games.
The simplest way to save a hangman game is probably as a straight text file with two lines of text:
MATCHWORD
GUESSESOFAR
So if I was playing with the word "CROSSFIRE" and I had guessed 'A', 'R', 'S' and 'P' your save file would be:
CROSSFIRE
ARSP
To generate the file is easy:
string matchWord = "CROSSFIRE";
string triedLetters = "ARSP";
File.WriteAllText(@"D:\Temp\mySaveFile.SAV", string.Format("{0}\n{1}", matchWord, triedLetters));
To read it back is pretty easy too:
string[] lines = File.ReadAllLines(@"D:\Temp\mySaveFile.SAV");
if (lines.Length == 2)
{
matchWord = lines[0];
foreach (char c in lines[1])
{
Guess(c);
}
}
[edit]I forgot a close bracket :O - OriginalGriff[/edit]