actual question:
What is the best practice to modify text-files without changing their encoding?
Background info:
I am a bit ashamed that I fail to do this. What I actually want to do is what any texteditor does: Open, modify and save a large number of text-based files, without accidently modifying more than I want to.
string s = System.IO.File.ReadAllText(path);
System.IO.File.WriteAllText(path, s);
This will both use a default encoding. I can also provide a specific encoding as parameter. Both is not what I want. How do I easily autodetect the encoding to be able to read and write without changing it?
Best wishes, Janis