Let me Know when to use CFile::Close(); 
Author Message
 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();
************************************



Mon, 09 Jul 2001 03:00:00 GMT  
 Let me Know when to use CFile::Close();
Check to make sure Read() isn't throwing an exception for some reason.
Otherwise, no idea. :-)


Tue, 10 Jul 2001 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Opening and closing a file on a Novell network using CFile

2. please let me know how i can

3. Closing a file, file handle, let me explain.

4. Let me know

5. Please let me know about Download dialog box programming

6. Please let me know where to find odbc.inf file required by SQLInstallODBC

7. How to let client know a full control on the server is updated

8. Please let me know about Download dialog box programming

9. CFile file closing

10. Problem with CFile::Close

11. Problem with write using CFile and read using fscanf()

12. How to let Full control using dialog template?

 

 
Powered by phpBB® Forum Software