我用Serialize保存我的信息的时候,我只保存了一个"hello",为什么我存的文件有几k?

Ailong 2003-09-29 11:26:17
ps:我用的CRichEditView
...全文
69 13 打赏 收藏 转发到动态 举报
写回复
用AI写文章
13 条回复
切换为时间正序
请发表友善的回复…
发表回复
__________________ 2003-09-29
  • 打赏
  • 举报
回复
Serialize要保存一个动态的对象的所有信息。多出的是对象的类与运行时信息数据!
Ailong 2003-09-29
  • 打赏
  • 举报
回复
谢谢,可能我的机器有病毒吧。我的怎么就不一样啊。。给分了
bluebohe 2003-09-29
  • 打赏
  • 举报
回复
我测试了代码了,绝对是六个字节,呐,新建一个基于CRichEditView的单文档工程,把它的Serialize(CArchive& ar)函数全部替换为以下代码:
{
CString m_strFormatString;
if (ar.IsStoring())
{
// TODO: add storing code here
m_strFormatString="ABCDE";
ar<<m_strFormatString;
}
else
{
// TODO: add loading code here
ar>>m_strFormatString;
}

// Calling the base class CRichEditDoc enables serialization
// of the container document's COleClientItem objects.
// TODO: set CRichEditDoc::m_bRTF = FALSE if you are serializing as text
CRichEditDoc::m_bRTF = FALSE;
CRichEditDoc::Serialize(ar);
}
bluebohe 2003-09-29
  • 打赏
  • 举报
回复
我测试了代码了,绝对是六个字节,呐,新建一个基于CRichEditView的单文档工程,把它的Serialize(CArchive& ar)函数全部替换为以下代码:
{
CString m_strFormatString;
if (ar.IsStoring())
{
// TODO: add storing code here
m_strFormatString="ABCDE";
ar<<m_strFormatString;
}
else
{
// TODO: add loading code here
ar>>m_strFormatString;
}

// Calling the base class CRichEditDoc enables serialization
// of the container document's COleClientItem objects.
// TODO: set CRichEditDoc::m_bRTF = FALSE if you are serializing as text
CRichEditDoc::m_bRTF = FALSE;
CRichEditDoc::Serialize(ar);
}
Ailong 2003-09-29
  • 打赏
  • 举报
回复
bluebohe(薄荷),你自己测试了这个代码的吗?我用了你得更大了,16k大小!
我再说一边,我用的是CRichEditView,摆脱各位告诉我前先测试一下。下面就是文件内容:用txt方式打开的

邢唷? > ? ? ??R o o t E n t r y  ?    R o o t E n t r y  0苕hX喢 @ C o n t e n t s    ?????ABCDE
sjzxyg 2003-09-29
  • 打赏
  • 举报
回复
你是不是看错了,把占用空间大小看成文件大小了
bluebohe 2003-09-29
  • 打赏
  • 举报
回复
if (ar.IsStoring())
{
// TODO: add storing code here
m_strFormatString="ABCDE";
ar<<m_strFormatString;
}
else
{
// TODO: add loading code here
ar>>m_strFormatString;
}

CRichEditDoc::m_bRTF = FALSE;
CRichEditDoc::Serialize(ar);
bluebohe 2003-09-29
  • 打赏
  • 举报
回复
CString m_strFormatString;
if (ar.IsStoring())
{
// TODO: add storing code here
m_strFormatString="ABCDE";
ar<<m_strFormatString;
}
else
{
// TODO: add loading code here
ar>>m_strFormatString;
}

// Calling the base class CRichEditDoc enables serialization
// of the container document's COleClientItem objects.
// TODO: set CRichEditDoc::m_bRTF = FALSE if you are serializing as text
CRichEditDoc::m_bRTF = FALSE;
CRichEditDoc::Serialize(ar);
Ailong 2003-09-29
  • 打赏
  • 举报
回复
if (ar.IsStoring())
{
// TODO: add storing code here
ar<<m_strFormatString;
}
else
{
// TODO: add loading code here
ar>>m_strFormatString;
}

就这么简单,我用的View类是CRichEditView类,是不是和这个相关?
bluebohe 2003-09-29
  • 打赏
  • 举报
回复
主要看你Serialize是怎么写的
wuxfBrave 2003-09-29
  • 打赏
  • 举报
回复
刚刚试过6个字节
if (ar.IsStoring())
{ // storing code
CString str = "hello";
ar << str;
}
else
{ // loading code
}
whoo 2003-09-29
  • 打赏
  • 举报
回复
看看hello后面有没有跟着垃圾。
wuxfBrave 2003-09-29
  • 打赏
  • 举报
回复
你的serialize写得是不是有问题啊

16,471

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • Web++
  • encoderlee
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……

试试用AI创作助手写篇文章吧