void ReadChinaMap()
{
CFile fCHIO;
CString Temp;
int nLength;  //文件的长度
char *pInfile; //文件内容的暂时存放处
char *pFileName = "CHIO.BNA";
CFileException e; if( !fCHIO.Open( pFileName, CFile::modeRead, &e ) )
{
#ifdef _DEBUG
afxDump << "File could not be opened " << e.m_cause << "\n";
#endif
   } nLength=fCHIO.GetLength();
pInfile=new char[nLength];
fCHIO.Read(pInfile,nLength);
Temp.Format("%s",pInfile);   //现在文件到了CString里了
};
编译一切正常,但是文件却打不开,我在目录下和debug目录下都放了CHIO.BNA这个文件。大家帮我想想原因在哪里?

解决方案 »

  1.   

    不是这个问题,我都试过了。
    还是不能解决。我查了一下fCHIO.m_strFileName也是正确的。
    不知道为什么就是打不开来。
      

  2.   


    #define DATA_FILE_T  ("CHIO.BNA")
    试试
      

  3.   

    试了,还是不行。没有错误码,但有这样一个框,写着如下内容。
    Debug Assertion Failed!Program: D:\locater\Debug\MainProject.exe
    File:filecore.cpp
    Line:258For information on how your program can cause an assertion failure,
    see the Visual C++ documentation on asserts
      

  4.   

    我发现一个问题,大家再帮我看一下。
    CHIO.BNA是个文本文件,当读取第一行的时候,带有“则什么都读不出来。
    我把“删掉,就可以读出来。
    这是为什么呀?