比如 for(int i=dlg->m_startline;i<dlg->ida+1;i++)
{
user_name = dlg->m_list.GetItemText(i-1,1);
passwd = dlg->m_list.GetItemText(i-1,2);
        Email = dlg->m_list.GetItemText(i-1,3);
buffok = buffok+dlg->m_list.GetItemText(i-1,1)+" "+dlg->m_list.GetItemText(i-1,2)+" "+dlg->m_list.GetItemText(i-1,3)+"\n";
CStdioFile file;   
file.Open(savefile,CFile::modeCreate | CFile::modeWrite); 
file.WriteString(buffok);   
        file.Close(); 
}这样的话 
buffok 会越来越大 
我现在想要存储50W行以上  
如何在在TXT文件内容的后面继续写  而不是 把数据都放入buffok里面 让后写入 
这样太慢了 

解决方案 »

  1.   

    不是有个追加模式么? fopen (xx, "a+")
      

  2.   

    将文件映射到内存写入     CreateFile CreateFileMapping  SetFilePointer
      

  3.   

    buffok = buffok+dlg->
    红的不要。你那个i是取一行,就把这行写入就行了,怎么又把上一行加进去了?
      

  4.   

    http://hi.baidu.com/wangguang246/blog/item/a8b1a583d6989bb26d811959.html
      

  5.   

    CStdioFile::ReadString 可以逐行读取文本,你根据这个来判断是否到了文件最后一行不就可以了吗?
      

  6.   

    file.WriteString(buffok);   
      file.Close();  
    在for循环内,那当然就不对了!移到for外!
      

  7.   

    1>.Create 时:
    CFile::modeNoTruncate   Combine this value with modeCreate. If the file being created already exists, it is not truncated to 0 length. Thus the file is guaranteed to open, either as a newly created file or as an existing file. This might be useful, for example, when opening a settings file that may or may not exist already. This option applies to CStdioFile as well.
    2》。open后
    CFile::SeekToEnd