-
May 17th, 2011, 07:38 AM
#1
VC++ File Handling for CString.
Hello all,
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?
Thanks a lot in advance.
-
May 17th, 2011, 07:42 AM
#2
Re: VC++ File Handling for CString.
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.
The easiest method is CStdioFile::WriteString()
-
May 17th, 2011, 11:26 AM
#3
Re: VC++ File Handling for CString.
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.
-
May 17th, 2011, 12:02 PM
#4
Re: VC++ File Handling for CString.
Originally Posted by nitinmalapalli
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.
-
May 17th, 2011, 12:41 PM
#5
Re: VC++ File Handling for CString.
Thanks a lot! I think i can close this thread now. I got all the information i needed. Thanks again.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|