How to append to a file using CFile (CArchive)
-
I'm using MFC to write to a file, but it seems that it likes to overwrite the file. I thought the CFile::NoTruncate tag would do it, but I seem to be wrong. I'm using CArchive to do the file I/O. Thanks for your time =)
Try:
CFile::Seek(0, CFile::end); //Places the file pointer at EOF. Proceed from there... :cool:
**--BlackSmith--
**/*The roof is on fire, we don't need no water, let the MF burn*/. BHG.
-
Try:
CFile::Seek(0, CFile::end); //Places the file pointer at EOF. Proceed from there... :cool:
**--BlackSmith--
**/*The roof is on fire, we don't need no water, let the MF burn*/. BHG.
This maybe too late but good for some old MFC folks like me: If the file does not exist, create it using CStdioFile: if (!pfile.Open(fileName,CFile::modeReadWrite)) { pfile.Open(fileName,CFile::modeCreate|CFile::modeReadWrite); } pfile.SeekToEnd(); MFC forever!!!
henryh