Generally, "using" is preferred approach for accessing and disposing of a filestream properly.
I often need to leave the file open (as below). Can the "using" structure be employed in this case?
public class logger
{
private StreamWriter sw;
public logger(string fileName)
{
sw = new StreamWriter(fileName, true);
}
public void LogString(string txt)
{
sw.WriteLine(txt);
sw.Flush();
}
public void Close()
{
sw.Close();
}
}