在vc中用fopen写入一个文本文件,但用fclose无法关闭,是不是这个文件被其他进程占用了

来源:百度知道 编辑:UC知道 时间:2024/06/05 03:07:38
怎样以独占方式对文件操作,这样能不能解决

CFile::modeDenyRead打开文件拒绝其它进程对文件的读访问
CFile::modeDenyWrite打开文件拒绝其它进程对文件的写访问

每次都失败吗?是否是多线程,你一个线程关闭了,其他的线程又打开了?

调用int _fcloseall( void );
The _fcloseall function closes all open streams except stdin, stdout, stderr (and, in MS-DOS, _stdaux and _stdprn). It also closes and deletes any temporary files created by tmpfile

没这么悬吧,你怎么知道是没关闭呢,是没开还是没关~~