请教CArchive运行报错的问题,谢谢!
相关源代码:
CFile file.Open(name, CFile::modeCreate||CFile::modeWrite);
CArchive ar1(&file, CArchive::store);
elecInfoOutput.Serialize(ar1);
ar1.Close(); // <--这行报错
file.Close();
报错时的堆栈状态:
CFile::Write(const void * 0x003468f0, unsigned int 4051) line 238 + 28 bytes
CArchive::Flush() line 649
CArchive::Close() line 481
CLeftView::OnProjectOutput() line 226
报错时的调试跟踪代码:(\MFC\SRC\Filecore.cpp)
void CFile::Write(const void* lpBuf, UINT nCount)
{
ASSERT_VALID(this);
ASSERT(m_hFile != (UINT)hFileNull); // <--指向这一行
if (nCount == 0) return; // avoid Win32 "null-write" option
// ... 下面省略了
}
附带说明:
1。elecInfoOutput是自定义的结构,调试时能够正确进行序列化,应该没什么问题。
2。name指定的文件是新的,连路径也是,所以调用了CFile::modeCreate||modeWrite
3。这个错误俺不知道为啥,诸位能帮帮忙吗?
4。再拜!谢啦!