Solved

Easy: Append line to CStdioFile

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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
configuration management 2 100
bobThere java chalenge 45 85
sum28 challenge 31 96
either24  challenge 19 84
Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
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 demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

747 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

12 Experts available now in Live!

Get 1:1 Help Now