用CFile类时,遇到“试图越过其尾端对一个未命名的文件进行读写”

一般问题是:

已经没数据了,你还要读,或者试图读取并不存在的数据 就会出错;报这种错误!!!

举个函数如:

 C++ Code 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
// 数据成员序列化
void CFileDLoadInfo::Serialize( CArchive& ar )
{
    CObject::Serialize( ar ); 
     if ( ar.IsStoring() )
    {
        ar << prototcal << threadCnt << savepath << downloadLink
            << strFileNames << strFileType << strFileSize << strFileProgress 
            << strFileUseTime << strFileCreateDate << dwFileSize << dwDownloadSize
            << bResume << bSupportResume  /*<< tempFile << cfgFile*/;   // 注释掉的部分
         //Store other members
    }
     else
    {
        ar >> prototcal >> threadCnt >> savepath >> downloadLink
            >> strFileNames >> strFileType >> strFileSize >> strFileProgress 
            >> strFileUseTime >> strFileCreateDate >> dwFileSize >> dwDownloadSize
            >> bResume >> bSupportResume  >> tempFile >> cfgFile;
         //Polymorphic reconstruction of persistent object 
         //load other members
    }

     return;
}
但我们存档的时候,如上面的if语句部分,我们本没有存入“ << tempFile << cfgFile”:   而在读取的时候else语句部分却有“ << tempFile << cfgFile”,那么就会报类似标题错误!!!




  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值