你好像不该用catch(...)   你用catch(CFileException *e)试试

解决方案 »

  1.   

    楼上的不对,
    catch(...)上面代码肯定是出错了
      

  2.   

    用catch(CFileException *e)
    你可以得到它的具体错误,可能你的文件路径不对,打不开
      

  3.   

    我试过,一切正常,注意你的文件是否存在,并且单步DEBUG,看看错在哪里。
      

  4.   

    CFile不行么? CFile filetxt;
    filetxt.Open ("c:\\dt900\\up\\data.txt",CFile::modeRead);
    int nLengh=filetxt.GetLength ();
      

  5.   

    FILE *fp;                      
    int len; if(m_strSourceFile=="")
    {
    AfxMessageBox("Please Select a Bin File to Convert.");
    return;
    }
    if(m_strConvertFile=="")
    {
    AfxMessageBox("Please Select a Txt File to Save.");
    return;
    } UpdateData(true); if(!(f.Open(m_strSourceFile,CFile::modeRead)))
    {
    AfxMessageBox("Open File:"+m_strSourceFile+" Error!");
    return;
    }
    len=f.GetLength();
      

  6.   

    int i=0;
                      int k=0;
    FILE *file;
    file=fopen(filepath,"r");
    while(!feof(file))
    {
    fread(tmp+i++,1,1,file);
    }
    k=i-1;
    fclose(file);
    这个k值不就是文本文件的长度吗?呵呵!
      

  7.   

    把文本文件读入一个CString,再用CString.GetLength()
      

  8.   

    你先判断打开文件是否成功然后再用GetFileSize获得文件长度。
    CStdioFile f1;
    if( !f1.Open( pFileName, CFile::modeCreate
           | CFile::modeWrite | CFile::typeText ) ) {
       #ifdef _DEBUG
          afxDump << "Unable to open file" << "\n";
       #endif
       exit( 1 );
      

  9.   

    发错了,不知按了什么键,就贴出去了,还不能修改,ft.
    文本文件的大小没试过,不过CStdioFile用的时候有点问题.
    我以前都用FILE *fp的.