There is a StringBuilder from which we get the text we want to write. But here's the problem, I tried two ways to write to the file.
Initial data:sb is the same StringBuilderfullFileName is the full path to the * .csv file format
The first way:
var file = Encoding.UTF8.GetBytes(sb.ToString()); File.WriteAllBytes(fullFileName, file); The second way:
System.IO.File.WriteAllText(fullFileName, sb.ToString(), Encoding.UTF8); I looked in Notepad ++ , the first method writes the file in the “UTF8 (Without BOM)” encoding, and the second one in “UTF8” . The second file has no problems with the encoding and everything is readable, and the first one gives out krakozyabra, all this when opening in Excell. File format * .csv . Please explain what is the cause of the problem and how can it be solved in the first method?