Please help! CFileException compile error for ->m_cause 
Author Message
 Please help! CFileException compile error for ->m_cause

Ken,

the problem is that you're using the dereference operator for a pointer
"->", but the object you have "fileException" is a CFileException object,
not a pointer to one.

Try this:

        if ( fileException.m_cause == ...

The reason the example uses the "->" syntax is because you get a pointer to
a CFileException object when an exception is actually thrown.  In those
cases, you'd use:

        if ( pfileException->m_cause == ...

Hope that helps.

---
Scott Smith



Quote:
> I am getting an error that CFileException has no -> operator for the
> following code in VC 4.2 on WIn95:

>  char* pszFileName = "c:\\PCLOCNAM.dat";
>      CFile cfPcLocationName;
>      CFileException fileException;

>      if ( !cfPcLocationName.Open( pszFileName,    
>                                CFile::modeRead,

> &fileException ) )
>          {
>           if(fileException->m_cause == CFileException::fileNotFound )
>                  {
>                       PCLocationDialog locationDialog;
>                       int locationDialog.DoModal();
>                  }
>              else
>                  {
>                   TRACE( "Can't open file %s, error = %u\n",
>                        pszFileName, fileException.m_cause );
>                   AfxMessageBox("Can't open PC Location file
> C:\\PCLOCNAM.DAT.  You must resolve this before continuing.",
>                                    MB_OK);
>                   return FALSE;
>                  }
>          }
>     My use of ->m_cause comes right from the on-line help.  Since Open
> doesn't throw an exception, it appears that I need to check
> fileException myself.  Why won't this compile?  I copied it right ouf of
> help basically.  Thanks.

> Ken Litwak




Mon, 07 Jun 1999 03:00:00 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. Compile Error=> Need help from expert

2. compile error : please help

3. compile time error. please help

4. Compile Errors -- Please Help

5. Compile error C2065 - please help !

6. Help, please: C1083 error while compiling

7. MFC compile error, please help

8. Compile Error-2nd Req (Please help)

9. Compiling Error Please Help!

10. help w/ compile/link error please.

11. Compile error C2259...please help

12. Please Help: link Error when compiling CWaitDailog

 

 
Powered by phpBB® Forum Software