Udostępnij za pośrednictwem


CFile Class

The base class for Microsoft Foundation Class file classes.

class CFile : public CObject

Remarks

It directly provides unbuffered, binary disk input/output services, and it indirectly supports text files and memory files through its derived classes. CFile works in conjunction with the CArchive class to support serialization of Microsoft Foundation Class objects.

The hierarchical relationship between this class and its derived classes allows your program to operate on all file objects through the polymorphic CFile interface. A memory file, for example, behaves like a disk file.

Use CFile and its derived classes for general-purpose disk I/O. Use ofstream or other Microsoft iostream classes for formatted text sent to a disk file.

Normally, a disk file is opened automatically on CFile construction and closed on destruction. Static member functions permit you to interrogate a file's status without opening the file.

For more information on using CFile, see the articles Files in MFC and File Handling in the Run-Time Library Reference.

Requirements

Header: afx.h

See Also

Tasks

DRAWCLI Sample: Illustrates Integrating Active Container Support with Application-Specific Features

Reference

CObject Class

Hierarchy Chart

CStdioFile Class

CMemFile Class

Other Resources

CFile Members

How Do I: Use the CFile Class?