Solved

Easy: Append line to CStdioFile

Posted on 1999-01-03
1
2,825 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
repeateFront java challenge 31 92
Smart Camera scanning and reading information 3 99
no14 challenge 14 62
child constructor and parent constructor, overriding and overloading 6 77
In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
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 …
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.
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

932 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now