I have many files contains some string. I want to replace this string with another value in all these files.
The files may have different encodings and extentions.
So, I'm using next method for all files
void ReplaceInFile(string file, string oldValue, string newValue)
{
string text = File.ReadAllText(file);
text = text.Replace(oldValue, newValue);
File.WriteAllText(file, text);
}
But I'm not sure I will not broke some of them, which has some unusual encoding. Am I right?
What else I can use to do this operation for files with different encodings?
How can I check that nothing broken?