Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C++/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 at 16-Aug-12 14:37pm
   
Read lines and if you do not want them, don't write them back out.
Kenneth Haugland at 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 at 16-Aug-12 23:22pm
   
My 5.
Espen Harlinn at 17-Aug-12 4:12am
   
Thank you, Abhinav :-D
AlluvialDeposit at 17-Aug-12 3:08am
   
5'ed
Espen Harlinn at 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 at 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
0 Sergey Alexandrovich Kryukov 766
1 OriginalGriff 345
2 CPallini 200
3 PIEBALDconsult 150
4 Magic Wonder 131
0 OriginalGriff 5,795
1 Sergey Alexandrovich Kryukov 5,028
2 CPallini 4,700
3 George Jonsson 3,142
4 Gihan Liyanage 2,450


Advertise | Privacy | Mobile
Web01 | 2.8.140916.1 | Last Updated 6 Sep 2012
Copyright © CodeProject, 1999-2014
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