Solved

Append mode?

Posted on 2001-06-19
3
488 Views
Last Modified: 2013-11-20
This might sound like an easy question but anyway:) How do we open a file in append mode in MFC??
0
Comment
Question by:mejaz01
3 Comments
 
LVL 12

Expert Comment

by:migel
Comment Utility
Hi!
you can use _open file with  _O_APPEND flag
and then use CFile constructor with getted file handle
i.e.
int flH = _open( "OPEN.OUT", _O_WRONLY | O_APPEND|_O_BINARY|_O_CREAT, _S_IREAD | _S_IWRITE );

CFile file(flH);
note that this file will not be closed in the file destructor so
use:
 _close((HFILE)file);
;
0
 
LVL 2

Accepted Solution

by:
TravisHall earned 50 total points
Comment Utility
Use CFile::modeNoTruncate (combined with CFile::modeCreate). To append to the end of the file, I think you will have to follow up your CFile::Open() with CFile::SeekToEnd().
0
 

Author Comment

by:mejaz01
Comment Utility
I found out a better way to do that. So I just think it's nice to let you know as well

EXAMPLE

     ofstream outs;
     outs.open("somefile", ios::app);
     outs<<"AnyString"<<endl;
     outs.close();
*------------
so ios::app is the append mode:)))
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

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…
Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
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.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

763 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

9 Experts available now in Live!

Get 1:1 Help Now