Overloading the two arguments to AppendAllText () completes the call to the internal File.InternalAppendAllText() method using UTF-8 encoding without specification:
[SecuritySafeCritical] public static void AppendAllText(string path, string contents) { if (path == null) { throw new ArgumentNullException("path"); } if (path.Length == 0) { throw new ArgumentException( Environment.GetResourceString("Argument_EmptyPath")); } File.InternalAppendAllText(path, contents, StreamWriter.UTF8NoBOM); }
Therefore, you can write:
using System.IO; using System.Text; File.AppendAllText(filename, text, new UTF8Encoding(false, true));
FrΓ©dΓ©ric hamidi
source share