Generally, โuseโ is the preferred approach for properly accessing and removing the filter.
I often need to leave the file open (as shown below). Can a โusingโ structure be used 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(); } }
source share