Computer Science Canada Save/Load stats from text file |
Author: | element4l [ Sat Dec 15, 2007 12:52 pm ] | ||
Post subject: | Save/Load stats from text file | ||
OK, I have a Tic Tac Toe game, and I wanted to add a feature that if the user types their name as one of the players, the program should go look in a text file (already created by the program) and check if it can find the same name. Then it should be able to read, for example, how many times that person has won, how many times they have lost, etc. But here's my problem, I want the info to show up inside different textboxes. So basically I'm looking for a way to read each line individually, checking if it matches with a variable (supplied by the user) then reading the following 4 lines, where each line has a number. The following is a snippet of codet that I am using in order to write to the text file, and it works great. But I have no idea how I could store info from those files into several variables.
Thanks for any help at all. |
Author: | Euphoracle [ Sat Dec 15, 2007 6:19 pm ] |
Post subject: | RE:Save/Load stats from text file |
Use a StreamReader and do <name>.ReadLine()? Who said .Net didn't make sense |
Author: | element4l [ Sun Dec 16, 2007 1:00 am ] | ||
Post subject: | Re: Save/Load stats from text file | ||
I've decided to settle on saving everything to the player's name text file, which I can easily work on, but when I try reading a text file that has something written in it, it says "The process cannot access the file 'C:\Tic-Tac-Toe\Profiles\Player 1.txt' because it is being used by another process." This doesn't happen when I take off the "statRead" process. So I'm assuming the problem is in there. If you find any french text in there, don't bother asking. the project is to be done in french, since I go to a french school. I just prefer "programming" in english if you know what I mean. If the following code is useful at all, not all of it is important.
|