◄CObject► ◄Up► ◄Contents► ◄Index► ◄Back► ──Microsoft Foundation Classes────────────────────────────────────────────── Description CFile is the base class for Microsoft Foundation file classes. 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 Foundation 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 I/O stream 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 file status without opening the file. #include <afx.h> See Also ◄CStdioFile►, ◄CMemFile► Public Members Data Members ◄m_hFile► Usually contains the operating-system file handle. Construction/Destruction ◄CFile► Constructs a CFile object from a path or file handle. ◄~CFile► Destroys the object, closing the file if it is open. ◄Duplicate► Constructs a duplicate object based on this file. ◄Open► Safely opens a file with an error-testing option. ◄Close► Closes a file and deletes the object. Input/Output ◄Read► Reads (unbuffered) data from a file at the current file position. ◄Write► Writes (unbuffered) data in a file to the current file position. ◄Flush► Flushes any data yet to be written. Position ◄Seek► Positions the current file pointer. ◄SeekToBegin► Positions the current file pointer at the beginning of the file. ◄SeekToEnd► Positions the current file pointer at the end of the file. ◄GetLength► Obtains the length of the file. ◄SetLength► Changes the length of the file. Locking ◄LockRange► Locks a range of bytes in a file. ◄UnlockRange► Unlocks a range of bytes in a file. Status ◄GetPosition► Gets the current file pointer. ◄GetStatus► Obtains the status of this open file. Static ◄Rename► Renames the specified file (static function). ◄Remove► Deletes the specified file (static function). ◄GetStatus► Obtains the status of the specified file (static, virtual function). ◄SetStatus► Sets the status of the specified file (static, virtual function). -♦-