|
Hi Yasir,
When I use the CFile::Read and CFile::Write functions on an open CFile object it works fine, I can save the string obtained from the open dialog box to a text file However when I write a class that have several strings as member variables, then serialize them into a CArchive object by overriding the Serialize function like the following:
void CMyClass::Serialize(CArchive& ar) { CObject::Serialize(ar); if(ar.IsStoring()) ar << StringOne << StringTwo << StringThree<< StringFour;
else ar >> StringOne>> StringTwo >> StringThree >> StringFour; }
Where the strings are the member variables of CMyClass. I then save the CArchive variable ar to file as follows
if(theFile.Open("hostDetails.dat",
CFile::modeCreate|CFile::modeNoTruncate|CFile::modeWrite)) { CArchive ar(&theFile,CArchive::store); Serialize(ar); ar.Close(); theFile.Close(); }
where theFile is a declared CFile object. This has worked fine for me many times, and I use it for CObList linked lists as well. But if one of those strings is from an open dialog box obtained with GetPathName() it won't save no matter what I do. Why??
Best regards,
Peter
|