Solved

Easy: Append line to CStdioFile

Posted on 1999-01-03
1
2,890 Views
Last Modified: 2013-11-20
Here's an easy one for you experts...
I need to open a file and append one line to it. I tried the following code, but it just overwrites the text in the file:

CStdioFile objFile( (LPCTSTR) m_strCurrentExportFile,  CFile::modeCreate |CFile::modeWrite |CFile::typeText );
         
objFile.SeekToEnd();
objFile.WriteString( (LPCTSTR) strOutput );      
objFile.Close();

0
Comment
Question by:MelissaC
1 Comment
 
LVL 12

Accepted Solution

by:
migel earned 50 total points
ID: 1327155
Hi! Yor modes for opening file is incorrect. CFile:modeCreate - truncate file to 0 if it already exist. You must check if file to append already exist and add CFile::modeCreate if it isn`t true.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
while loop over for loop 7 116
has22 challenge 11 107
Trying to run powershell  in a batch file. How do I do this? 8 117
Not needed 13 129
Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question