Mega Code Archive

 
Categories / C# / File Stream
 

Create StreamWriter class for the specified stream, using the specified encoding and the default 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 swFromFile = new StreamWriter(logFile);             swFromFile.Write(textToAdd);             swFromFile.Flush();             swFromFile.Close();     } }