Create UTF8 encoding StreamWriter from File name
using System;
using System.IO;
public class SWBuff
{
public static void Main(String[] args)
{
string logFile = "a.log";
string fileName = "a.log";
string textToAdd = "asdf";
FileStream fs = new FileStream(fileName, FileMode.CreateNew, FileAccess.Write, FileShare.None);
StreamWriter swFromFileTrueUTF8 = new StreamWriter(fileName, true,System.Text.Encoding.UTF8);
swFromFileTrueUTF8.Write(textToAdd);
swFromFileTrueUTF8.Flush();
swFromFileTrueUTF8.Close();
}
}
Related examples in the same category