#MFC Help Contradiction
3 messages in this thread
I believe that I have found a contradiction in the documentation of
CFile, regarding whether destroying an open CFile will cause the associated
operating system file to be closed.
Below are excerpts from the on-line MFC 2.5 help file:
from CFile::Close :
" Closes the file associated with this object and makes the file
unavailable for reading or writing. If you have not closed the
file before destroying the object, the destructor closes it for you. "
from CFile::CFile :
" When the CFile object is destroyed the operating-system file
will not be closed. You must close the file yourself. "
Which one is right?
Justin Grant
JG> I believe that I have found a contradiction in the
JG> documentation of CFile, regarding whether destroying an
JG> open CFile will cause the associated operating system file
JG> to be closed.
JG>
JG> Which one is right?
They both are :). Actually, if the ctor CFile::CFile( int hFile ) is used (in
other words, a CFile object is attached to an existing open file),
CFile::~CFile() will *not* close it. Otherwise, if the file is opened by
CFile::Open(), it *will* be closed by the dtor. (Check out the source file
FILECORE.CPP and note the m_bCloseOnDelete member of CFile).
gc
Norman, Oklahoma USA
— "Is that a *real* poncho or is that a *Sears* poncho?"
Gary—
I had already found out about m_bCloseOnDelete by the time I got your
message, but I didn't know the bit about its use varying by the type of ctor
used. Thanks for the info.
Justin