积极答复者
复合文档的问题

问题
-
在MFC程序中用COleDocument,然后发现每次保存文件后,用UntralEdit打开文件,文件的字节都在增长,这是为什么
void CDocTest3Doc::Serialize(CArchive& ar)
{
if (ar.IsStoring())
{
// TODO: add storing code here
ar<<m_str;
}
else
{
// TODO: add loading code here
ar>>m_str;
}// Calling the base class COleDocument enables serialization
// of the container document's COleClientItem objects.
COleDocument::Serialize(ar);
}
答案
-
因为COleDocument::Serialize(ar);创建的文件头不是写在文件开头,
The following is signature, not part of post
Please mark the post answered your question as the answer, and mark other helpful posts as helpful, so they will appear differently to other users who are visiting your thread for the same problem.
Visual C++ MVP- 已建议为答案 shawken 2011年12月28日 16:26
- 已标记为答案 Helen Zhao 2012年1月9日 1:35
全部回复
-
因为COleDocument::Serialize(ar);创建的文件头不是写在文件开头,
The following is signature, not part of post
Please mark the post answered your question as the answer, and mark other helpful posts as helpful, so they will appear differently to other users who are visiting your thread for the same problem.
Visual C++ MVP- 已建议为答案 shawken 2011年12月28日 16:26
- 已标记为答案 Helen Zhao 2012年1月9日 1:35
-
呃,这个增量保存的行为是你的代码有bug造成的……写文件头信息的应该放在函数开头
The following is signature, not part of post
Please mark the post answered your question as the answer, and mark other helpful posts as helpful, so they will appear differently to other users who are visiting your thread for the same problem.
Visual C++ MVP -
是的
不过如果你启用了复合文件的话,应该只调用基类来保存COleClientItem
The following is signature, not part of post
Please mark the post answered your question as the answer, and mark other helpful posts as helpful, so they will appear differently to other users who are visiting your thread for the same problem.
Visual C++ MVP