I know for a fact that VC++ 4.0 (MFC 4.0) doesn't close CFiles immediately.
I needed to write an NT command script (.CMD) and execute it. After closing
the script, it didn't seem to matter how long I waited (checked up to 5
minutes), but the file wouldn't execute - it had an open error reported by
CMD.EXE saying the file was locked by another user/application. As soon as
I switched to K&R stdio functions, everything worked, even without a wait.
Next time, I'll try the _commit() call after my data is written and before
closing.
Thanks,
Mike Ober.
Quote:
> I think it does close the file right away when you call CFile::Close(),
but
> you might want to try something like:
> CFile m_MyFile;
> _commit(m_MyFile.m_hFile);
> to get your data to flush out. There is a CFile equivalent called:
> m_MyFile.Flush()
> but it doesn't seem to always work.
> HTH,
> Tom