Click here to Skip to main content
12,444,360 members (53,870 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: MFC
Hi,

Please let me know,how can I remove each lines in the file using CFile class.

-Abhi
Posted 16-Aug-12 8:31am
Comments
Wes Aday 16-Aug-12 14:37pm
   
Read lines and if you do not want them, don't write them back out.
Kenneth Haugland 16-Aug-12 15:05pm
   
Im having a hard time to decide if its a text line or a real line in a drawing program, still wondering ;)
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

Modifying CFileFinder - Extend the functionality of CFileFind MFC class[^] should be fairly straight forward.

Best regards
Espen Harlinn
  Permalink  
Comments
Abhinav S 16-Aug-12 23:22pm
   
My 5.
Espen Harlinn 17-Aug-12 4:12am
   
Thank you, Abhinav :-D
AlluvialDeposit 17-Aug-12 3:08am
   
5'ed
Espen Harlinn 17-Aug-12 4:13am
   
Thank you, AlluvialDeposit :-D
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 2

what do you want?
remove a certain text in file or a line?
if you mean a line, do it :
in a loop write lines until you arrive to that.
then read that line but don't write.
after that in a loop write remainder lines.

CFile f;
f.Open(_T("path of the file"),CFile::modeRead|CFile::modeWrite);
 
read function is :
f.Read(buffer,count);
 
write function is:
f.Write(buffer,count);
 
f.Close();
  Permalink  
v2
Comments
Richard MacCutchan 6-Sep-12 9:43am
   
Please use <pre> tags around code blocks for clarity (as I have done for you).

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.160811.3 | Last Updated 6 Sep 2012
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100