Create StreamWriter with encoding
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 swFromFileStreamDefaultEnc = new System.IO.StreamWriter(fs, System.Text.Encoding.Default);
swFromFileStreamDefaultEnc.Write(textToAdd);
swFromFileStreamDefaultEnc.Flush();
swFromFileStreamDefaultEnc.Close();
}
}
Related examples in the same category