Dela via


Files in MFC

In the Microsoft Foundation Class Library (MFC), class CFile handles normal file I/O operations. This family of articles explains how to open and close files as well as read and write data to those files. It also discusses file status operations. For a description of how to use the object-based serialization features of MFC as an alternative way of reading and writing data in files, see the article Serialization.

Note

When you use MFC CDocument objects, the framework does much of the serialization work for you. In particular, the framework creates and uses the CFile object. You only have to write code in your override of the Serialize member function of class CDocument.

The CFile class provides an interface for general-purpose binary file operations. The CStdioFile and CMemFile classes derived from CFile and the CSharedFile class derived from CMemFile supply more specialized file services.

For more information about alternatives to MFC file handling, see File Handling in the Run-Time Library Reference.

For information about derived CFile classes, see the MFC hierarchy chart.

What do you want to do?

Use CFile

Use MFC Serialization (Object Persistence)

See Also

Concepts

General MFC Topics

Reference

CArchive Class

CObject Class

Other Resources

MFC Concepts

How Do I: Use the CFile Class?