Saving/loading files from within program - Page 2
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 2 of 2 FirstFirst 12
Results 16 to 17 of 17

Thread: Saving/loading files from within program

  1. #16
    Join Date
    Sep 2007
    Posts
    103

    Re: Saving/loading files from within program

    Ok, I seem to have finally been able to find this.

    To save a file:

    Code:
    CFile theFile;
    theFile.Open(_T("myfile.fmt"), CFile::modeCreate | CFile::modeWrite);
    CArchive archive(&theFile, CArchive::store);
    Serialize(archive);
    archive.Close();
    theFile.Close();
    The page where I found this code did not list how to load files, but the following seems to work for me:

    Code:
    CFile theFile;
    theFile.Open(_T("myfile.fmt"), CFile::modeRead);
    CArchive archive(&theFile, CArchive::load);
    Serialize(archive);
    archive.Close();
    theFile.Close();
    Here, the .fmt part of myfile.fmt is whichever format you are using.

  2. #17
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Location
    Florida
    Posts
    12,504

    Re: Saving/loading files from within program

    I told you just call OnSaveDocument. It does all that stuff for you.

Page 2 of 2 FirstFirst 12

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This a Codeguru.com survey!


On-Demand Webinars (sponsored)