Create StreamWriter from FileStream
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 swFromFileStream = new StreamWriter(fs);
swFromFileStream.Write(textToAdd);
swFromFileStream.Flush();
swFromFileStream.Close();
}
}
Related examples in the same category