CFile Class
The base class for Microsoft Foundation Class file classes.
class CFile : public CObject
Members
Public Constructors
Name |
Description |
---|---|
Constructs a CFile object from a path or file handle. |
Public Methods
Name |
Description |
---|---|
Closes a file ignoring all warnings and errors. |
|
Closes a file and deletes the object. |
|
Constructs a duplicate object based on this file. |
|
Flushes any data yet to be written. |
|
Retrieves the filename of the selected file. |
|
Retrieves the full file path of the selected file. |
|
Retrieves the title of the selected file. |
|
Retrieves the length of the file. |
|
Retrieves the current file pointer. |
|
Retrieves the status of the open file, or in the static version, retrieves the status of the specified file (static, virtual function). |
|
Locks a range of bytes in a file. |
|
Safely opens a file with an error-testing option. |
|
Reads (unbuffered) data from a file at the current file position. |
|
Deletes the specified file (static function). |
|
Renames the specified file (static function). |
|
Positions the current file pointer. |
|
Positions the current file pointer at the beginning of the file. |
|
Positions the current file pointer at the end of the file. |
|
Sets the full file path of the selected file. |
|
Changes the length of the file. |
|
Sets the status of the specified file (static, virtual function). |
|
Unlocks a range of bytes in a file. |
|
Writes (unbuffered) data in a file to the current file position. |
Public Operators
Name |
Description |
---|---|
A handle to a CFile object. |
Public Data Members
Name |
Description |
---|---|
Determines if the CFile object has a valid handle. |
|
Usually contains the operating-system file handle. |
Protected Data Members
Name |
Description |
---|---|
Pointer to CAtlTransactionManager object. |
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.
Inheritance Hierarchy
CFile
Requirements
Header: afx.h