建立一个单文档项目,工具栏上不是有个保存图标,程序如下
void CSeriolView::OnFileSave() //文件保存
{
// TODO: Add your command handler code here
CString strFilePath;
strFilePath = this->GetDocument()->GetPathName();
if ("" == strFilePath)
{
CString m_sNowDataPath = "C:\\";
CString str = m_sNowDataPath + "*.*"; CFileDialog dlg( TRUE,_T("*"), str, //XD: 从对话框中读
 OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT,
 _T( "All Files|*.*|" "Data Files|*.Dat|") );
if( dlg.DoModal()==IDCANCEL )
{
return ;
}
strFilePath = dlg.GetPathName();
}
//怎么获得文件内容
this->GetDocument()->OnSaveDocument(strFilePath);
this->GetDocument()->SetPathName(strFilePath);
this->GetDocument()->SetTitle(strFilePath);
}
新建个文档,然后输入内容,然后点保存
在保存之前偶要对文件内容进行操作,应该这么做,就是偶要拿到文件的内容!

解决方案 »

  1.   

    有没有
    this->GetDocument()->???//把文档内容取出来的函数this->GetDocument()->OnSaveDocument(strFilePath);//这个是保存文件,那文件的内容捏?
    偶保存前还要对文件内容排序先
      

  2.   

    可以把文本读出前两行,然后比较,然后依次比较下去再排序。函数如下:
      void ReadStringBug()
       {
            CString strBuffer;
            CStdioFile sfMyFile( "C:\\test.txt", CFile::modeRead );        sfMyFile.ReadString( strBuffer );
            AfxMessageBox( strBuffer );
            sfMyFile.ReadString( strBuffer );
            AfxMessageBox( strBuffer );
       }
      

  3.   

    单文档视图
    this->GetDocument()->OnSaveDocument(strFilePath);//
    this->GetDocument()->SetPathName(strFilePath);
    this->GetDocument()->SetTitle(strFilePath);CSeriolDoc* CSeriolView::GetDocument() // non-debug version is inline
    {
    ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CSeriolDoc)));
    return (CSeriolDoc*)m_pDocument;
    }
    比如我新建个文档,然后编辑,我怎么获得编辑的内容吧,肯定有函数吧?
    可能是沟通有问题吧。。大家都不大理解我的意思