Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Problem with serialization

Problem with serialization

Scheduled Pinned Locked Moved C / C++ / MFC
c++databasejsonhelpquestion
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    heavenode
    wrote on last edited by
    #1

    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; }

    L 1 Reply Last reply
    0
    • H heavenode

      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; }

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      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

      H 1 Reply Last reply
      0
      • L Lost User

        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

        H Offline
        H Offline
        heavenode
        wrote on last edited by
        #3

        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'.

        R 1 Reply Last reply
        0
        • H heavenode

          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'.

          R Offline
          R Offline
          Ravi Bhavnani
          wrote on last edited by
          #4

          You may find this[^] series of articles interesting. /ravi My new year's resolution: 2048 x 1536 Home | Music | Articles | Freeware | Trips ravib(at)ravib(dot)com

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups