John black
John black

Reputation: 527

Store information in file - What way?

My app reads questions and their answers. Now I have to make it store them and read them from HDD. The idea is to read all data and store it in memory on app initialization, because speed is important.

But the problem is I lack the model of storing all this information in a file. I've been working with ini files only, but file size is limited and it is SO slow to read.

Could you please suggest a model and a sample? Thanks!

Upvotes: 2

Views: 907

Answers (3)

niemiro
niemiro

Reputation: 1838

Is this some sort of quiz, student and teacher sides, for creating and using the questions? How many questions could this get to? You would probably be looking at making a proper database, or more easily, XML or binary serialisation. Have a look at these links. They were written for .net 2, but are very nicely done, and should be perfectly usable:

XML: http://www.switchonthecode.com/tutorials/csharp-tutorial-xml-serialization

File (binary) Less human readable: http://www.switchonthecode.com/tutorials/csharp-tutorial-serialize-objects-to-a-file

You don't even have to keep it as the same extension either, although I will not recommend that either way. I quite like the look of the second link for you, with a personalised file extension.

Good luck!

Upvotes: 0

ChristopheD
ChristopheD

Reputation: 116117

You could use the nice SQLite flat file database (this allows you to use standard SQL to select / update / insert your data).

.NET bindings are available here. A starters tutorial can be found here.

Upvotes: 3

HSBallina
HSBallina

Reputation: 434

Just an idea. I had kind of the same issue. For keeping it simple (I didn't have any db available) I used lists of classes for maintaining the data in memory and then used XML-serialization to store them on disk between sessions. Maybe not the purest of models but simple enough.

Upvotes: 1

Related Questions