I am working on a project and i need to save a CString to a file and load it back later. I found out that i could use:
1.) the CFile method.
2.) the CArchive method.
3.) the fstream method.
What are the various advantages/disadvantages of using any of these methods? Which one should I use for my basic file handling purposes? How do I write a CString to file?
Do you actually need a CString object or just text?
Archiving is good if you have a complex class structure and need to save and restore it intact. For just a line of text, it's probably not the best approach.
It is actually a custom-made table which has 5 fields to each entry and possibly hundreds of such entries.
Could CArchive possibly help reduce a great deal of effort? All the entries are contained in a class called CFJTable which may perhaps be saved as one unit.
My other option is to save each field of each entry into the file, while introducing some character for separation between each field and each entry.
It is actually a custom-made table which has 5 fields to each entry and possibly hundreds of such entries.
Could CArchive possibly help reduce a great deal of effort? All the entries are contained in a class called CFJTable which may perhaps be saved as one unit.
My other option is to save each field of each entry into the file, while introducing some character for separation between each field and each entry.
Thanks for replying, GCDEF.
Sounds like Serialization is what you want then. As long as everything you want to save is derived from CObject, it's pretty easy to use.
Bookmarks