In this post we will be discussing about writing text files without Byte Order Mark. The below code snippet will help you to write text files without byte order mark.
In Visual Basic
In C#
You can omit BOM only for UTF-8 not for UTF-16. Please like and share the CodingDefined.com blog if you find it helpful and interesting.
In Visual Basic
Dim newVariable As New System.Text.UTF8Encoding(true) Using streamWriter As New StreamWriter("NewFile.txt", False, newVariable) streamWriter.WriteLine("Text goes here") End Using
In C#
var newVariable = new System.Text.UTF8Encoding(true) using(var streamWriter = new StreamWriter("NewFile.txt", False, newVariable) { streamWriter.WriteLine("Text goes here"); }
You can omit BOM only for UTF-8 not for UTF-16. Please like and share the CodingDefined.com blog if you find it helpful and interesting.
No comments:
Post a Comment