\doc\web\98\01\archive.txt Arthur Hu C++ gotcha file 1-6-97 Keywords: Microsoft MFC/Visual C+++, archive, serialize Question: I'm trying to write out and read back an archive, but the file does not write - it creates the file of 0 length, but there's nothing to read back. Answer: The file won't actually be written out until the CFile destructor is called. The solution is to write the statements inside a block so that after you are done, the local stack-allocated CFile object is destroyed without having to return from another routine level. Or put the code into another level, which is probably a good idea anyway if there is any complexity at all. { // Need to either put this in a "block, or put it into // its own procedure entirely. CFile ProbeWriteFile; CFileException fileException; CString ProbeFileName = _T("probe.prb"); CArchive ArchiveWrite (&ProbeWriteFile, CArchive::store); GProbeCard->Serialize (ArchiveWrite); } // file will be zero length until it gets this far // now ready to read the file back in