Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

CFile: Checking if file is open

512 views
Skip to first unread message

nntp.ext.ray.com

unread,
Feb 1, 2001, 4:35:25 AM2/1/01
to
Is there any way of checking if a file is already open, to prevent me
calling close on it twice.

Thanks

Peter Barber


Philo Dough

unread,
Feb 1, 2001, 8:15:02 AM2/1/01
to
why not try some kind of an operation on the file
like a rewind , or something . if the operation
succeeds , then , viola' , the file's open ...
hope this helps

"nntp.ext.ray.com" <peter....@raytheon.co.uk> wrote in message
news:45ae6.90$3d3....@dfw-service2.ext.raytheon.com...

David Crow [MCSD]

unread,
Feb 1, 2001, 9:51:11 AM2/1/01
to
Compare m_hFile against CFile::hFileNull. Remember, when your CFile object
goes out of scope, the file will get closed automatically.

"Philo Dough" <g@m.c> wrote in message news:ewxs#DFjAHA.1944@tkmsftngp02...

Michael D. Ober

unread,
Feb 1, 2001, 9:53:04 AM2/1/01
to
I have discovered that the auto closure of the file appears to occur in a
seperate thread that MFC runs at low priority. If you need to guarantee a
file is closed, wrap the CFile::Close() method in a try/catch and ignore the
error that says the file wasn't open.
--
Mike Ober.

"David Crow [MCSD]" <david.cr...@ndchealth.com> wrote in message
news:NIee6.41$yJ1.45@client...

0 new messages