CString.Replace not working?

I am using MFC VC++ 6.
my aim is to search for a string in a text file, replace it with another string and write to another file..
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22

	CString str;
	
	CFile file;
	
	if(file.Open("check.txt", CFile::modeRead))
		
	{
		
		int len = file.GetLength();
		file.Read(str.GetBuffer(len), len);
		file.Close();	
	}
	str.Replace(_T("old"),_T("new"));

CStdioFile file2;

if(file2.Open("test.txt", CFile::modeCreate|CFile::modeWrite))
{
  file2.WriteString(str);
  file2.Close();
}

This compiles fine, but both the files are same (string is not replaced)
Please i need urgent help..
Regards
Last edited on
Topic archived. No new replies allowed.