Problem with serialization
-
I'm writing a simple flat file database MFC SDI application. However after i save n close the file, i cant open it again and shows 'unexpected file format'. below is my serialize funcation for the new class, the sequence is correct. What other problem can it be? void CPerson::Serialize(CArchive &ar) { CObject::Serialize(ar); if (ar.IsStoring()) ar << m_sName << m_sRoom << m_iSex << m_iStatus; else ar >> m_sName >> m_sRoom >> m_iSex >> m_iStatus; }
-
I'm writing a simple flat file database MFC SDI application. However after i save n close the file, i cant open it again and shows 'unexpected file format'. below is my serialize funcation for the new class, the sequence is correct. What other problem can it be? void CPerson::Serialize(CArchive &ar) { CObject::Serialize(ar); if (ar.IsStoring()) ar << m_sName << m_sRoom << m_iSex << m_iStatus; else ar >> m_sName >> m_sRoom >> m_iSex >> m_iStatus; }
What are the data types for the member variables and if you open file were the contents saved as expected ? Do a test with CString variables to make a test file if you are uncertain about what should happen when storing. Elaine :rose: The tigress is here :-D
-
What are the data types for the member variables and if you open file were the contents saved as expected ? Do a test with CString variables to make a test file if you are uncertain about what should happen when storing. Elaine :rose: The tigress is here :-D
Problem solved, there's nothing wrong with the code. actually i have another similar application, it's because the save-filetype (fdb) for both applications are the same, so when i save using the second application, the window uses my first application to open and resulting in 'unexpected file format'.
-
Problem solved, there's nothing wrong with the code. actually i have another similar application, it's because the save-filetype (fdb) for both applications are the same, so when i save using the second application, the window uses my first application to open and resulting in 'unexpected file format'.