Set StreamWriter buffer size
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 swFromFileStreamUTF8Buffer = new StreamWriter(fs, System.Text.Encoding.UTF8, 512);
swFromFileStreamUTF8Buffer.Write(textToAdd);
swFromFileStreamUTF8Buffer.Flush();
swFromFileStreamUTF8Buffer.Close();
}
}
Related examples in the same category