Storing a high score list
-
I've actually written a program - I'll post it later, but right now, I'm having difficultly with this problem: storing a high sore list. I'd prefer a cross-platform (should be generic enough to also work on Mono) way to store the scores and some other variables in a text file, and easily read, parse into a ListView/DataGridView and write. I don't want to use SQL Server or Access, as they are overkill for my needs.
People think it must be fun to be a super genius, but they don't realize how hard it is to put up with all the idiots in the world. - Calvin (from Calvin and Hobbes)(The Indispensable Calvin and Hobbes, p105-3)
XML.
-
I've actually written a program - I'll post it later, but right now, I'm having difficultly with this problem: storing a high sore list. I'd prefer a cross-platform (should be generic enough to also work on Mono) way to store the scores and some other variables in a text file, and easily read, parse into a ListView/DataGridView and write. I don't want to use SQL Server or Access, as they are overkill for my needs.
People think it must be fun to be a super genius, but they don't realize how hard it is to put up with all the idiots in the world. - Calvin (from Calvin and Hobbes)(The Indispensable Calvin and Hobbes, p105-3)
a simple text file could do; maybe a CSV; maybe XML. if sharing amongst multiple users is important, be careful about concurrent accesses. :)
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
Getting an article published on CodeProject now is hard and not sufficiently rewarded.
-
a simple text file could do; maybe a CSV; maybe XML. if sharing amongst multiple users is important, be careful about concurrent accesses. :)
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
Getting an article published on CodeProject now is hard and not sufficiently rewarded.
I'm not too worried about sharing - it's all in the user's home directory (my excess Linux use is reflecting off Windows, wow) and I'd like a nice simple two-way wrapper. If I can read it with foreach, it shouldn't be too hard to add the items into a ListView... BTW, CP seems to randomly barf XML errors after loading various pages, so if you see a double post, not my fault.
People think it must be fun to be a super genius, but they don't realize how hard it is to put up with all the idiots in the world. - Calvin (from Calvin and Hobbes)(The Indispensable Calvin and Hobbes, p105-3)
-
I'm not too worried about sharing - it's all in the user's home directory (my excess Linux use is reflecting off Windows, wow) and I'd like a nice simple two-way wrapper. If I can read it with foreach, it shouldn't be too hard to add the items into a ListView... BTW, CP seems to randomly barf XML errors after loading various pages, so if you see a double post, not my fault.
People think it must be fun to be a super genius, but they don't realize how hard it is to put up with all the idiots in the world. - Calvin (from Calvin and Hobbes)(The Indispensable Calvin and Hobbes, p105-3)
File.ReadAllLines() and string.Split(',') make reading a CSV quite easy. XML is an alternative, easy once you know your way around in the Xml classes. Serialization is also a possibility.
The Cake of Deceit wrote:
CP seems to randomly barf XML errors
never seen that myself. you might bring it up in the suggestions forum, best with URL of pages that (sometimes) do it, plus details on your OS and browser. :)
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
Getting an article published on CodeProject now is hard and not sufficiently rewarded.
-
I'm not too worried about sharing - it's all in the user's home directory (my excess Linux use is reflecting off Windows, wow) and I'd like a nice simple two-way wrapper. If I can read it with foreach, it shouldn't be too hard to add the items into a ListView... BTW, CP seems to randomly barf XML errors after loading various pages, so if you see a double post, not my fault.
People think it must be fun to be a super genius, but they don't realize how hard it is to put up with all the idiots in the world. - Calvin (from Calvin and Hobbes)(The Indispensable Calvin and Hobbes, p105-3)
FileHelpers[^] is an excellent library for working with various file formats. Check out the home page[^]
I know the language. I've read a book. - _Madmatt
-
FileHelpers[^] is an excellent library for working with various file formats. Check out the home page[^]
I know the language. I've read a book. - _Madmatt
Nice find - I'll be checking this one out myself :thumbsup:
Dave
If this helped, please vote & accept answer!
Binging is like googling, it just feels dirtier. (Pete O'Hanlon)
BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) -
File.ReadAllLines() and string.Split(',') make reading a CSV quite easy. XML is an alternative, easy once you know your way around in the Xml classes. Serialization is also a possibility.
The Cake of Deceit wrote:
CP seems to randomly barf XML errors
never seen that myself. you might bring it up in the suggestions forum, best with URL of pages that (sometimes) do it, plus details on your OS and browser. :)
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
Getting an article published on CodeProject now is hard and not sufficiently rewarded.
Luc Pattyn wrote:
string.Split(',') make reading a CSV quite easy
Not if the CSV has commas in the values, e.g.
...,"Pattyn, Luc",...
-
Luc Pattyn wrote:
string.Split(',') make reading a CSV quite easy
Not if the CSV has commas in the values, e.g.
...,"Pattyn, Luc",...
I would never do that. That deserves two fields. When I use CSV, I choose my comma carefully; and when in doubt I remove it from the data fields when storing! In general, you're right of course. :)
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
Getting an article published on CodeProject now is hard and not sufficiently rewarded.
-
I would never do that. That deserves two fields. When I use CSV, I choose my comma carefully; and when in doubt I remove it from the data fields when storing! In general, you're right of course. :)
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
Getting an article published on CodeProject now is hard and not sufficiently rewarded.
Well, book or movie titles that include commas.
Luc Pattyn wrote:
I choose my comma carefully
Yes, one should never use a comma as a comma. :-D I've known people to only use Caret (^) as the delimiter because it's unlikely to be in the data. I just prefer to put quotes around string values just because.
Luc Pattyn wrote:
In general, you're right of course.
I think I'll post that on my wall.
-
Well, book or movie titles that include commas.
Luc Pattyn wrote:
I choose my comma carefully
Yes, one should never use a comma as a comma. :-D I've known people to only use Caret (^) as the delimiter because it's unlikely to be in the data. I just prefer to put quotes around string values just because.
Luc Pattyn wrote:
In general, you're right of course.
I think I'll post that on my wall.
PIEBALDconsult wrote:
I think I'll post that on my wall.
Why, it isn't there yet? :laugh:
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
Getting an article published on CodeProject now is hard and not sufficiently rewarded.
-
I'm not too worried about sharing - it's all in the user's home directory (my excess Linux use is reflecting off Windows, wow) and I'd like a nice simple two-way wrapper. If I can read it with foreach, it shouldn't be too hard to add the items into a ListView... BTW, CP seems to randomly barf XML errors after loading various pages, so if you see a double post, not my fault.
People think it must be fun to be a super genius, but they don't realize how hard it is to put up with all the idiots in the world. - Calvin (from Calvin and Hobbes)(The Indispensable Calvin and Hobbes, p105-3)
hi brother i search from someone who can make small program for me if u can tell me f0f020002000@yahoo.com
-
hi brother i search from someone who can make small program for me if u can tell me f0f020002000@yahoo.com
-
File.ReadAllLines() and string.Split(',') make reading a CSV quite easy. XML is an alternative, easy once you know your way around in the Xml classes. Serialization is also a possibility.
The Cake of Deceit wrote:
CP seems to randomly barf XML errors
never seen that myself. you might bring it up in the suggestions forum, best with URL of pages that (sometimes) do it, plus details on your OS and browser. :)
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
Getting an article published on CodeProject now is hard and not sufficiently rewarded.
I'm dumbfrazzled myself. I just have two columns in the list view, and want to at least read the CSV and parse it in. I don't need to transform LV's into CSVs, as I write to the CSV. All I ask is for a simple way to read and write CSVs, with an easy to to add the CSV items into a list view. Nothing to complicated, just an int and string in two columns. If there are missing Cs, my keyboard's C key isn't very responsible, sorry about that.
People think it must be fun to be a super genius, but they don't realize how hard it is to put up with all the idiots in the world. - Calvin (from Calvin and Hobbes)(The Indispensable Calvin and Hobbes, p105-3)