Property Encoding
Encoding
Gets or sets the encoding the file is written in. Defaults to null, which writes UTF-8 with
no byte order mark.
public Encoding Encoding { get; set; }
Property Value
Remarks
Set this to write a mark, which is what a spreadsheet opening a CSV by double click needs before it will show accented text correctly: UTF8 carries one where the default does not. Set it to something else again for a consumer that cannot read UTF-8 at all, accepting that characters the target cannot represent are lost.
Code pages beyond the ones built in need
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance) before
GetEncoding(int) will return them.