Create 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"; StreamWriter swFromFileTrue = new StreamWriter(fileName,true); swFromFileTrue.Write(textToAdd); swFromFileTrue.Flush(); swFromFileTrue.Close(); } }