Click here to Skip to main content
15,884,099 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

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

-Abhi
Posted
Comments
[no name] 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 ;)

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

Best regards
Espen Harlinn
 
Share this answer
 
Comments
Abhinav S 16-Aug-12 23:22pm    
My 5.
Espen Harlinn 17-Aug-12 4:12am    
Thank you, Abhinav :-D
StianSandberg 17-Aug-12 3:08am    
5'ed
Espen Harlinn 17-Aug-12 4:13am    
Thank you, AlluvialDeposit :-D
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.

C++
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();
 
Share this answer
 
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)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900