Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Append mode?

Posted on 2001-06-19
3
Medium Priority
?
503 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 12

Expert Comment

by:migel
ID: 6208083
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 150 total points
ID: 6208600
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
ID: 6210897
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

Enroll in October's Free Course of the Month

Do you work with and analyze data? Enroll in October's Course of the Month for 7+ hours of SQL training, allowing you to quickly and efficiently store or retrieve data. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

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…
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
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.
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

604 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