
Let me Know when to use CFile::Close();
I met trouble in using CFile class
if i uncomment " nFile.Close(); "
I met trouble
why?
help me!
// Example
const int m_nLength = 100;
float m_fData[m_nLength];
for(int i=0;i<m_nLength;i++)
m_fData[i] = (float)sin(2*3.1415*i/m_nLength);
CFile outFile;
CFileException e;
if( !outFile.Open("c:\\test_bin.txt",
CFile::modeCreate| File::modeWrite, &e) )
{
#ifdef _DEBUG
afxDump << "File could not be opened " << e.m_cause << "\n";
#endif return;
}
outFile.Write((char*)m_fData,sizeof(float)*m_nLength);
outFile.Close();
for(i=0;i<m_nLength;i++) m_fData[i] = 0.f;
CFile inFile;
CFileException ee;
if( !inFile.Open("c:\\test_bin.txt",CFile::modeRead, &ee) )
{
#ifdef _DEBUG
afxDump << "File could not be opened " << ee.m_cause << "\n";
#endif return;
}
inFile.Read((char*)m_fData,sizeof(float)*m_nLength);
************************************
// nFile.Close();
************************************