我查了下MSDN,以下是相关描述:
CArchive::bNoFlushOnDelete 
Prevents the archive from automatically calling Flush when the archive destructor is called. If you set this flag, you are responsible for explicitly calling Close before the destructor is called. If you do not, your data will be corrupted.这个属性设置的目的是 在对象析构之前,自己显式调用CArchive::Close()函数;但是Close()函数的作用是:
Flushes any data remaining in the buffer, closes the archive, and disconnects the archive from the file.
这里也是需要清除缓冲的。 
问题是:什么情况下要设置这个属性,为什么要设置这个属性?

解决方案 »

  1.   

    CArchive类在析构时会自动调用Flush清楚缓存,bNoFlushOnDelete 标记设置后析构函数不会自动调用Flush,因此需要在析构前调用close以实现缓存数据的保存。bNoFlushOnDelete 一般和其他两项配合一起用
      

  2.   


    既然无论如何都是要清除缓存的,那何必设置这样一个属性来区分呢?
    请问为什么要设置这么一个属性呢?这两种情况有什么 除了调用Close()/Flush()位置不同外 还有什么不同?
      

  3.   

    作用是防止不可预料的错误,如出现异常,此时析构函数调用flash函数的话会导致保存或读入错误的数据
      

  4.   

    http://support.microsoft.com/kb/157073/zh-tw
    析构函数中清楚缓存是不可控制的,不能完全确定是否完成了要求的操作,最好能通过flash或close函数清除缓存