Hello.

My intention is to read each line from a file and save it into a STL list of CString. So if there are 10 lines in the file, then the linked list of CString will be of size ten. Prosise demonstrates a very effective way to read and write from and to a file linewise using the CStdioFile class. However, in doc/view, MFC turns to Serialization. The problem, to me, with Serialization is I do not know what is going on in the background. I do not know what the framework does to the data in terms of CArchive.

When writing to CArchive, I use this:

for (iter = list.begin(); iter != list.end(); ++iter)
ar << *iter;

I am not sure how to read data from CArchive back into the linked list. First, I do not know whether data is stored similar to a file, i.e. if you write line1 and line2, then you can read back line1 and line2 in its original form.

How should I go about read data from CArchive back into the linked list if I have no knowledge of how CArchive manages the orientation of the data?

For example let say that the linked list of CString has this:

-----
a
b
c
d
e
-----

Okay. When it stores the data into CArchive, I assumpt it stores it like this:

<- a <- b <- c <- d <-e

However, if I have no prior knowledge of what was in the CArchive, how do I go about saving the data from CArchive back into the linked list?

Thanks,
Kuphryn

Note: If nothing works, I think the technique Prosise shows is best since class CStdioFile features ReadString() and WriteString().