Dear All,
I having a problem here.
I'm trying to append data to a CFile using FILE*
But when execute the application, it always give error saying "No such file or directory".
I can actually see the file created but it just keep giving error "No such file or directory".
Is the file being lock or the file just created so it can not be find by fstream(FILE*)?
or the file mode is wrong?
Can somebody help me with this:
Below is the code:
[QUOTE]
void SaveDocument(CString strFile)
{
CFile file;
if( !file.Open(strFile, CFile::modeCreate | CFile::modeWrite | CFile::shareDenyNone))
{
CArchive ar(&file, CArchive::store);
// save now.
MyClass.Serialise(ar);
ar.Flush();
ar.Close();
file.Close();
}
}
void MyClass::Serialize(CArchive &ar)
{
if(ar.IsStoring())
{
ar << parameter1;
ar << parameter2;
...
ar.Flush();
CFile *pFile = ar.GetFile();
int fd = _open_osfhandle((long)(pFile->m_hFile), _O_APPEND); // fd is > 0
FILE *pFILE = NULL;
pFILE = _wfdopen(fd, _T("a+"));
CString str;
str = strerror(errno);
AfxMessageBox(str); // <=Here always give "No such file or directory"
}
}
[\QUOTE]
Attached is the printscreen of the FILE* pointer. the pointer is evaluated as bad pointer.
Why the FILE* pointer not able point to the file being created?
Thanks.