'I am seeing Invalid characters during a find and replace c#

Newbie here, please help. I have a text file on my PC when I read it and do a find ’ and replace it with ' After saving the file, the replaced character looks like this: � How can I do the find and replace to have this character ' instead of �

My code:

string text = File.ReadAllText("C:\file.txt") ;
text = text.Replace("’", "'");
File.WriteAllText("C:", file2.txt);

I tried UnicodeToUTF8(text)



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source