September 26th, 2012, 10:12 PM
Append Data to CFile via FILE*
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:
void SaveDocument(CString strFile)
if( !file.Open(strFile, CFile::modeCreate | CFile::modeWrite | CFile::shareDenyNone))
CArchive ar(&file, CArchive::store);
// save now.
void MyClass::Serialize(CArchive &ar)
ar << parameter1;
ar << parameter2;
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+"));
str = strerror(errno);
AfxMessageBox(str); // <=Here always give "No such file or directory"
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?
Click Here to Expand Forum to Full Width
This a Codeguru.com survey!