Hi all
There seems to be alot of good knowledge around here so I though Id though up a question that Ive never really found a good answer to.
If writing an app that saves a heap of stuff in a text base file, ie like a word processor or something, what is the best way of making working data persistant?
* In perl you can link text files to hash tables - does c# have something similar?
* Ive seen arrays that read data in at startup, have changes made, and the text file is replaced with the array contents at end - problem here is what if the app crashes?
* Do you update a text file every time the array is updated, like search and replace - slow & system crash may cause undesired states?
* Do you update a text file every time the array is updated using an index, like count line and replace - slow & system crash may cause undesired states?
* Do you write to a temp file and then replace the old one once happy with temp file? - Still problem of when and how to write?
Also, as Im new to oop.. hard to change old ways, any suggestions for representing an object in a text file. I was just thinking if having a nice name propery in every object and writing that, seems like a waste of memory though..
Id like to get this right early on, instead of un-learning bad habits, so your feedback is much appreciated!!
Cheers..
There seems to be alot of good knowledge around here so I though Id though up a question that Ive never really found a good answer to.
If writing an app that saves a heap of stuff in a text base file, ie like a word processor or something, what is the best way of making working data persistant?
* In perl you can link text files to hash tables - does c# have something similar?
* Ive seen arrays that read data in at startup, have changes made, and the text file is replaced with the array contents at end - problem here is what if the app crashes?
* Do you update a text file every time the array is updated, like search and replace - slow & system crash may cause undesired states?
* Do you update a text file every time the array is updated using an index, like count line and replace - slow & system crash may cause undesired states?
* Do you write to a temp file and then replace the old one once happy with temp file? - Still problem of when and how to write?
Also, as Im new to oop.. hard to change old ways, any suggestions for representing an object in a text file. I was just thinking if having a nice name propery in every object and writing that, seems like a waste of memory though..
Id like to get this right early on, instead of un-learning bad habits, so your feedback is much appreciated!!
Cheers..