Follow the code below:
string text = File.ReadAllText($@"{pathname}", Encoding.UTF8);
I have several txt files with different conditioning. Because here does not show special characters, because of different encoding.
Before running the File.ReadAllText
line, how do I get the file type?
Example: ANSI, UNICODE, UTF-8, ETC ...
Something like this:
if (pathname == Encoding.ASCII)
{
string text = File.ReadAllText($@"{pathname}", Encoding.ASCII);
}
else if (pathname == Encoding.UTF8)
{
string text = File.ReadAllText($@"{pathname}", Encoding.UTF8);
}