Programming Windows with MFC - PowerPoint PPT Presentation

1 / 11
About This Presentation
Title:

Programming Windows with MFC

Description:

the CArchive Class. Serialization Basics. The and operators. Serialize variety of primitive data type, classes, and structures ... – PowerPoint PPT presentation

Number of Views:153
Avg rating:3.0/5.0
Slides: 12
Provided by: Jos421
Category:

less

Transcript and Presenter's Notes

Title: Programming Windows with MFC


1
Programming Windows with MFC
2
Chapter 6
  • File I/O and Serialization

3
CFile class
  • Document saving and loading
  • m_hFile
  • Public data member
  • Hold the handle of the file
  • m_strFilename
  • protected data member
  • Hold the file name
  • GetFilePath, GetFileName, and GetFileTitle
  • CArchive objects

4
Opening, Closing, and Creating Files
  • CFileOpen
  • CFileClose
  • CFileRead
  • CFileWrite

5
CFileOpen
  • CFile file
  • if (file.Open (_T ("File.txt"),
    CFilemodeReadWrite))
  • // It worked!

6
CFiles constructor
  • CFile file (_T ("File.txt"), CFilemodeReadWrite
    )
  • try
  • CFile file (_T ("File.txt"), CFilemodeReadWrit
    e)
  • catch (CFileException e)
  • // Something went wrong.
  • e-gtReportError ()
  • e-gtDelete ()

7
CFile Sharing Mode
8
CFile Access Mode
9
The CFile family
10
Serialization and the CArchive Class
11
Serialization Basics
  • The ltlt and gtgt operators
  • Serialize variety of primitive data type,
    classes, and structures
  • CArchive ar (file, CArchivestore)
  • ar ltlt a ltlt b
  • CArchive ar (file, CArchiveload)
  • ar gtgt a gtgt b
Write a Comment
User Comments (0)
About PowerShow.com