
A problem on loading file using CFile
I little problem in my program:
In the Document class:
void CMainDoc::Serialize(CArchive& ar)
{
if (ar.IsStoring())
{
// TODO: add storing code here
}
else
{
// TODO: add loading code here
MyClass cl;
cl.Load( ar.GetFile()->GetFilePath() );
}
Quote:
}
In MyClass:
bool MyClass::Load( CString* fn )
{
CFileException e;
CFile fn;
if (!fn.open( fn, CFile::modeRead, &e ))
{
#ifdef _DEBUG
afxDump << "File could not be opened " << e.m_cause << "\n";
#endif
return false;
}
.
.
Quote:
}
The program can be compiled but it cannot load the file all the time.
The e.m_cause returns 11 and i wonder what's wrong with my program
and how can i solve it?
Thanks
Kelvin Leung