C# - Save UTF-8 without BOM

To save a text file in C# without BOM (Byte Order Mark) you have to set the encoding like that:

var utf8WithoutBom = new System.Text.UTF8Encoding(false);
File.WriteAllText(_fileName, content, utf8WithoutBom);

The false in the encodings constructor tells so not write the byte order mark.

Werbung



comments powered by Disqus

Copyright Dunkel & Iwer GbR | Datenschutzerklärung | Impressum