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

I have one text file, now I want to find a string in that file and have to replace with some other string(nothing but find and replace a string in text file). I am trying to use CFile class in MFC, but it has limited methods to do such operations. can any body give some idea to accomplish this or if you have any such application please send me for reference.

Thanks in advance.

Regards,
anil
Posted

1 solution

Member 4399771 wrote:
I am trying to use CFile class in MFC, but it has limited methods to do such operations.


CFile provides file handling (open, close, read, write) methods, as it should. You have to
  1. Read the file (maybe partially) in a buffer (for instance in a CString object)
  2. do the replace operations in the buffer (CString class has methods to do it)
  3. Save the modified buffer to disk using, again, CFile.

:)
 
Share this answer
 
v2

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